80ps,求调

P1035 [NOIP2002 普及组] 级数求和

thomas1234567 @ 2024-09-09 18:55:52

#include<bits/stdc++.h>
using namespace std;
double sum=0;
int main()
{
    double n;
    cin>>n;
    for(double i=1;i<=1000000;++i)
    {
        sum=sum+1/i;
        if(sum>=n)
        {
            cout<<i;
            return 0;
        }
    }
}

by xujinxuan01 @ 2024-09-09 19:12:20

读题,注意不是S_n \ge k,是S_n > k


|