召唤师昧光 @ 2017-09-11 22:11:48
#include <stdio.h>
int main()
{
short int k,n;
double sn=0;
scanf("%d",&k);
for(n=1;sn<k;n++){
sn=sn+(1/n);
}
printf("%d",n-1);
return 0;
}
by Administrator2004 @ 2017-09-11 22:29:56
by 召唤师昧光 @ 2017-09-12 21:35:50
@Administrator2004 不行啊,改完以后超时了
by 召唤师昧光 @ 2017-09-13 21:47:24
别沉
by 召唤师昧光 @ 2017-09-16 21:19:41
没有人吗,为什么总是tle
by Lyricle @ 2017-09-16 22:29:40
Shortint是过不去咩
by 上官小胖 @ 2017-09-17 14:29:15
sn=sn+(1.00000000000000000/n);
输出改成n;
先弄个死循环,再循环里判断是否break
by 上官小胖 @ 2017-09-17 14:30:04
sn=sn+(1.00000000000000000/n);
输出改成n;
先弄个死循环,再循环里判断是否break
by 上官小胖 @ 2017-09-17 14:30:51
#include <bits/stdc++.h>
using namespace std;
double x;
long long n,ans=1;
int main()
{
cin>>n;
for (;;ans++)
{
x+=(1.00000000000000000/ans);
if (x>n)
break;
}
cout<<ans<<endl;
return 0;
}