5 条题解
- 1
信息
- ID
- 36
- 时间
- 1000ms
- 内存
- 125MiB
- 难度
- 1
- 标签
- 递交数
- 344
- 已通过
- 163
- 上传者
#include <bits/stdc++.h> using namespace std; int main() { int k, n = 1; double S = 0; cin >> k; while(S <= k) { S += 1.0 / n; ++n; } cout << --n << endl; return 0; }
#include <bits/stdc++.h>
using namespace std;
int main()
{
double s=0;
int n,i=1;
scanf("%d",&n);
while(s<n)
{
s+=1.0/i;
i++;
}
printf("%d",--i);
return 0;
}
大佬,为什么i要自减?