万人矣 @ 2019-08-16 23:08:56
using namespace std;
int main()
{
int K,n=1;
float S;
cin>>K;
S=1;
while(S<=K)
{
n++;
S=S+1.0/n;
}
cout<<n;
return 0;
}
by YZhe @ 2019-08-16 23:23:34
亲,这边建议使用插入代码功能呢
by SisconHL @ 2019-08-16 23:49:21
多打九个字符会死人吗
by jiangly @ 2019-08-16 23:57:57
@万人矣 可能是 float
精度不够
by DLSINNOCENCE @ 2019-08-17 08:53:25
#include <iostream>
using namespace std;
int main() {
int K,n=1;
double S;
cin>>K;
S=1;
while(S<=K) {
n++;
S=S+1.0/n;
}
cout<<n;
return 0;
}
@万人矣
by 万人矣 @ 2019-08-17 21:35:30
@jiangly @不匿名用户 谢谢!改过了,鞠躬/
by 万人矣 @ 2019-08-17 21:39:06
@Tryer 我还在纳闷为啥插不进代码呢[挠头],发现了,以后会的。还请多多指教。
by HugoKW @ 2019-08-21 10:44:26
把n=1改成n=0