Yu09217777 @ 2022-10-07 12:05:55
#include <bits/stdc++.h>
using namespace std;
int main(){
int k;
cin >> k;
double n = 0,sum = 0;
for(int i = 1;;i++){
sum += 1 / i * 1.0;
if (sum > k * 1.0){
break;
}
n++;
}
cout << n;
return 0;
}
by Ja50nY0un9_as_AgNO3 @ 2022-10-07 12:12:06
#include <bits/stdc++.h>
using namespace std;
int main(){
double k;
cin >> k;
int n = 0;
double sum = 0;
for(int i = 1;;i++){
sum += 1.0 / i;
if (sum >= k){
n++;
break;
}
n++;
}
cout << n;
return 0;
}
by liguorui2022 @ 2022-12-25 22:11:34
直接输出 i 就好了