sy_whwh @ 2020-05-30 10:10:20
#include<cstdio>
int main ()
{
int k;
long n=0;
float s=0;
scanf("%d",&k);
while(s<=k)
{
n++;
s+=1.0/n;
}
printf("%d",n);
}
by zhoukangyang @ 2020-05-30 10:14:47
@sy_whwh s改成double
by Alan_Zhao @ 2020-05-30 10:15:17
@sy_whwh float
不靠谱,换成double
就过了
by 是真的囬气 @ 2020-05-30 10:16:52
float换成double
by sy_whwh @ 2020-05-31 15:10:26
好的,谢谢大家的指点。
by skisd @ 2020-08-14 22:16:55
问一下为什么float不可以过呢
by 水滴探测器 @ 2020-08-18 09:18:58
@skisd float精度不够
by xtiger @ 2020-10-05 21:42:53
最好把printf中的%d改成%ld。