80求调

P1035 [NOIP2002 普及组] 级数求和

yurenjin @ 2024-12-09 19:10:35

#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 yise @ 2024-12-09 19:26:31

@yurenjin sum>n亲


by yurenjin @ 2024-12-09 20:35:28

@yise谢谢哈


|