哪错了

P1035 [NOIP2002 普及组] 级数求和

Luochenhao88 @ 2024-11-26 13:37:16

#include <bits/stdc++.h>
using namespace std;
int k,n;
double s,a=0;
int main(){
    cin>>k;
    for(int i=1;i<=99999;i++){
        a+=1.0/i;
        n++;
        if(a>k){
            i=100000;
        }
    }
    cout<<n;
    return 0;
}

by yzm0325 @ 2024-11-26 13:41:10

@Luochenhao88 枚举上界小了


by Luochenhao88 @ 2024-11-26 13:45:53

谢谢


|