GMLY @ 2024-11-17 19:07:58
救命
#include<bits/stdc++.h>
using namespace std;
int main(){
double ans=0;
int a;
cin>>a;
for(int i=1;;i++){
ans=ans+(1/i);
if(ans>a){
cout<<i;
break;
}
}
}
烦请各位改错!!!
by __Lovely_Keqing__ @ 2024-11-17 19:09:32
《1/i》 @GMLY
by GMLY @ 2024-11-17 19:12:40
@__Lovely_Keqing__
怎么了吗?(不解)
by 小小黑 @ 2024-11-17 19:16:25
写成1.0/i才是浮点运算
by GMLY @ 2024-11-17 19:17:05
@小小黑
哦哦,好的,谢谢