re市肾么洞悉吖

P1035 [NOIP2002 普及组] 级数求和

倪天灿 @ 2018-08-16 14:51:54

include<iostream>

include<cmath>

include<cstdio>

include<algorithm>

using namespace std; int main() { int k; cin>>k; double s=0.000000; for(double i=2;i<20000000000;i++) { s+=1/i; if(s>k) { cout<<i; break; } } return 0; }


by zclclWJN @ 2018-08-16 16:20:24

洛谷自动将iostream看成了

include<iostream>


by zclclWJN @ 2018-08-16 16:21:24

@倪天灿

include<iosteam>

#include<cstring>
#include<string>
using namespace std;
int k,n = 0;
int main() 
{
    cin >> k;
    for(double i = 1;i <= k+1;i = i+1.0/n)
        ++n;
    cout << n;
    return 0;
}

上一页 |