#include<bits/stdc++.h>
using namespace std;
int main() {
int n,m;
cin>>m; // 输入一个数 m
double sum=0; // 初始化总和为 0
for(int i=1;;i++){ // 从 1 开始循环,直到满足条件才会跳出循环
sum+=(double)1/i; // 每次将当前的倒数加到总和中
if(sum>=m){ // 如果总和大于等于 m,说明找到了满足条件的最小整数 n
n=i; // 将当前的 i 赋值给 n
break; // 跳出循环
}
}
cout<<n; // 输出结果 n
return 0;
}
01-17
286
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-15
6396
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-13
9746
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交