xing0324 @ 2025-01-10 19:29:24
sos,为什么6个测试点最后1个通不过???
#include<iostream>
using namespace std;
int main(){
int k,n=0;
cin>>k;
for(double sn=0;sn<k;n++,sn+=1.0/n);
cout<<n;
}
by xing0324 @ 2025-01-10 19:34:40
是"洛谷p1035";
by hex4C45 @ 2025-01-10 19:50:37
题目中是求最小的
所以循环条件应该是
sn<=k
而不是
sn<k
by hex4C45 @ 2025-01-10 19:53:13
@xing0324
by xing0324 @ 2025-01-10 20:12:11
哦,感谢dalao!!!