求助

P1035 [NOIP2002 普及组] 级数求和

Yangjingyu666 @ 2024-10-09 10:52:50

为什么我运行没问题但他给我显示WA


by chen_z @ 2024-10-09 11:13:59

@Yangjingyu666 WA是答案错误,即你的解法有误,和能否正常运行无关


by codm_man @ 2024-12-19 17:08:38

#include<bits/stdc++.h>
using namespace std;
int n;
double s=0,k=0;
int main() {
    cin>>n;
    while(1) {
        k++;
        s+=1/k;
        if(s>n) break;
    }
    cout<<(int)k;

}

@Yangjingyu666 求关


|