sangsang @ 2016-11-11 20:57:23
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int k;
double s,n;
cin>>k;
s=0;
for(int n=1;n<10000000000;n++)
{
s+=1/(double)n;
if(s>n)
{
break;
}
}
cout<<n;
return 0;
}
by winmt @ 2016-11-11 20:59:48
刚刚才解答过另一个人的同题疑问,见讨论。
给下代码:
#include<iostream>
using namespace std;
int main()
{
double N=1.0,K;
double S=0.0;
cin>>K;
while(1)
{
S=S+1.0/N;
if(S>K)break;
N++;
}
cout<<N;
return 0;
}
by winmt @ 2016-11-11 21:01:52
是:
if(s>k)
{
break;
}
吧 @sangsang
by winmt @ 2016-11-11 21:02:26
@sangsang
by 小水滴 @ 2016-11-15 14:29:42
你用10000000000肯定要超时