coderzhx @ 2024-06-08 12:33:38
#include <iostream>
using namespace std;
double sum = 0;
int k;
int cnt = 1;
int main() {
cin >> k;
while (sum < k) {
sum += 1. / cnt;
cnt++;
}
cout << cnt;
return 0;
}
by Special_Tony @ 2024-06-08 12:38:02
@Geyijinnoip 是<=,而且你最后要-1
by huangzhenyu01 @ 2024-06-08 13:31:59
你这哪一题???
by coderzhx @ 2024-06-08 18:53:23
@Special_Tony 为社么要-1???
by Special_Tony @ 2024-06-08 19:18:18
@Geyijinnoip -1是因为你最后一次加一多加了