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 imbecile @ 2020-05-17 14:04:29
@江户川·萝卜 哦,知道了
by 江户川·萝卜 @ 2020-05-17 14:04:30
或者直接输出的时候减一也可以
by imbecile @ 2020-05-17 14:05:28
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n=0,k;
double s=0.0;
cin>>k;
while(s<k)
{
n++;
s+=1.0/n;
}
scanf("%d",&n);
}
@Adhara 这样?
by 江户川·萝卜 @ 2020-05-17 14:05:41
wtf您别瞎用scanf啊。。。
by Adhara @ 2020-05-17 14:06:03
@zengxiangtuo scanf("%d",&n);
改成printf("%d\n",n);
by imbecile @ 2020-05-17 14:06:15
@江户川·萝卜 好的呢
by 江户川·萝卜 @ 2020-05-17 14:06:23
直接cout<<n
它不香吗
by imbecile @ 2020-05-17 14:06:47
@江户川·萝卜 md记错了
by imbecile @ 2020-05-17 14:07:46
@江户川·萝卜 过了谢谢大家
by 江户川·萝卜 @ 2020-05-17 14:07:50
前线传来令人振奋的消息:lz他A了!