I_love_Cathy @ 2022-10-12 19:54:11
求调
#include<bits/stdc++.h>
using namespace std;
int main(){
double n,i=1;
cin>>n;
double ans=0.00000000;
while(ans<n){
ans+=1.0000000/i;
i++;
}
cout<<i;
}
by CH_mengxiang @ 2022-10-12 19:58:55
记得-1再输出,代码中实际会多加一次
by codejiahui @ 2022-10-12 19:59:37
#include<iostream>
using namespace std;
int main()
{
double n,i = 1;
cin >> n;
double ans = 0;
while(ans <= n)
{
ans += 1.0 / i;
i++;
}
cout << i - 1 << endl;
}
by No1_TLEman @ 2022-10-12 20:13:41
#include<cstdio>
int main() {
int k,n=0;
scanf("%d",&k);
for(double Sn=0;Sn<=k;n++,Sn+=1.0/n);
printf("%d",n);
return 0;
}