alwayzsn @ 2019-10-09 22:09:22
#include<stdio.h>
int main()
{
float s = 0.0;
int k,i=0;
scanf("%d", &k);
while (s <= k);
{
i++;
s += 1.0 / i;
}
printf("%d", i);
return 0;
}
by Gerald_Chen @ 2019-10-11 23:37:01
@君梦如烟 1.0/i自动转浮点型运算,1/i是整型运算,向下取整。i>1的话,1/i就等于0,当然会超时
by 君梦如烟 @ 2019-10-12 21:42:32
@Gerald_Chen 谢谢鸭