谎言君_liar @ 2017-10-19 19:15:44
#include<iostream>
using namespace std;
int main()
{
int k,i;
long double sum;//sum为代数式的值
cin>>k;
sum=0;i=0;
while(sum<=k)
{
i=i+1;
sum=sum+(1.0/i);
}
cout<<i<<endl;
return 0;
}
by 谎言君_liar @ 2017-10-19 19:17:36
我的代码输出的值和复制题解输出的一样,为啥我的过不了
by My_Faith @ 2017-10-19 21:06:53
what 一百分啊
by My_Faith @ 2017-10-19 21:08:07
你想得两百分吗
by 谎言君_liar @ 2017-10-19 21:29:44
@pebble2007发错了,是这个代码
#include<bits/stdc++.h>
using namespace std;
int main(){
double k,p=0;
int n;
cin>>k;
for(double i=1;i<=10000000;i++){
n++;
p+=1.00000000/i;
if(p>k){cout<<n;break;
}
}
}
by 谎言君_liar @ 2017-10-19 21:33:10
@pebble2007
by My_Faith @ 2017-10-19 21:36:31
欧