#include<bits/stdc++.h>
using namespace std;
int main(){
int k,n=1;
double sum=1;
cin>>k;
while(sum<=k)
sum+=1.0/++n;
cout<<n;
return 0;
}
(洛谷)P1035 [NOIP2002 普及组] 级数求和
最新推荐文章于 2024-09-01 16:27:26 发布
#include<bits/stdc++.h>
using namespace std;
int main(){
int k,n=1;
double sum=1;
cin>>k;
while(sum<=k)
sum+=1.0/++n;
cout<<n;
return 0;
}