想求 a(n)≥c 中最小的 n。
a(n)=21+31+…+n+11
code:
#include<bits/stdc++.h>
using namespace std;
int main(){
double c;
while(cin>>c&&c!=0){
int ans=0;
double r=0;
while(r<c){
ans++;
r+=1/(ans+1);
}
cout<<ans<<endl;
}
return 0;
}
我就问问这怎么卡住了?(RE)
注意:不知道要判断多少个数