lukepanpyz @ 2023-08-04 15:49:59
WA code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int k;
cin >> k;
int n = 1;
double cnt = 0;
while(cnt <= k)
{
cnt += 1.0 / n;
n++;
}
cout << n;
return 0;
}
by Zz__Cc @ 2023-08-04 15:55:09
n要减1
by Zz__Cc @ 2023-08-04 15:56:00
输出前加个n -= 1;
by LoadingSpace @ 2023-08-04 15:57:05
1.n=0; 2. n++; cnt+=1.0/n; (反过来)
by lukepanpyz @ 2023-08-04 16:00:21
感谢各位大佬