lsilencej @ 2018-04-30 08:39:06
using namespace std; int main() { double sum,k,n; cin>>k; for(n=1;sum<=k;++n) { sum+=1/n; } cout<<n; return 0; }
by Siyuan @ 2018-04-30 09:35:56
#include <iostream>
using namespace std;
int main() {
double sum,k,n;
cin>>k;
for(n=1; sum<=k; ++n) {
sum+=1/n;
}
cout<<n;
return 0;
}
by Siyuan @ 2018-04-30 09:37:49
最后需要 n--
吧(因为每次都 n++
了)
by namespace_std @ 2018-04-30 22:31:40
溢出之后要减去1
by 凯皇6 @ 2018-07-14 08:39:54
__