imbecile @ 2020-05-17 13:52:55
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n=1,k;
double s=0.0;
cin>>k;
while(s<k)
{
s+=double(1/n);
n++;
}
cout<<n;
}
by andyli @ 2020-05-17 13:56:20
@zengxiangtuo s+=double(1/n);
改为s+=double(1)/n;
或s+=1.0/n;
by critnos @ 2020-05-17 13:56:51
一超时就有人说快读,,,这有不是 Ynoi
by 159号程序员 @ 2020-05-17 13:56:54
是的,防止死循环
by imbecile @ 2020-05-17 13:56:59
@江户川·萝卜 哦!懂了
by 159号程序员 @ 2020-05-17 13:57:31
改一下那行语句就对了,我和你写的很像
by Adhara @ 2020-05-17 13:58:02
就读一个数还用快读,真的服气。
by imbecile @ 2020-05-17 13:58:13
@159号程序员 哪一个 ?
by imbecile @ 2020-05-17 13:58:39
@andyli 改了,但是全部WA了
by 江户川·萝卜 @ 2020-05-17 13:58:52
等 一 下 最后输出还要将n-1吧
by 159号程序员 @ 2020-05-17 14:00:29
或者直接int n = 0;