倪天灿 @ 2018-08-16 14:51:54
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 倪天灿 @ 2018-08-16 16:06:30
5个wa
by zclclWJN @ 2018-08-16 16:06:53
@倪天灿 额?
by zclclWJN @ 2018-08-16 16:07:24
@倪天灿 有链接吗
by 倪天灿 @ 2018-08-16 16:09:03
要链接干什么
by zclclWJN @ 2018-08-16 16:10:01
@倪天灿 我只想看看哪一题,5个wa看不出来
by 倪天灿 @ 2018-08-16 16:10:24
p1035
by zclclWJN @ 2018-08-16 16:13:48
@倪天灿
#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;
}
by 倪天灿 @ 2018-08-16 16:18:15
@zclclWJN 写写大老
by 倪天灿 @ 2018-08-16 16:18:59
@zclclWJN 但是好像没iostream头文件
by zclclWJN @ 2018-08-16 16:19:22
你的代码没有从1开始
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
double k;
double s = 0.0;
int main()
{
cin >> k;
for(double i = 1;i < 20000000000;i++)
{
s += 1/i;
if(s > k)
{
cout << i;
break;
}
}
return 0;
}