68pts求助

P1035 [NOIP2002 普及组] 级数求和

Liyuhui222 @ 2025-01-08 10:02:14

6068pts求助

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

by Liyuhui222 @ 2025-01-08 10:04:59

@20141001_Zxz @Han_Si_Ying


by Liyuhui222 @ 2025-01-08 10:12:33

不用了,已AC


|