b用int试试
by xujiacheng0312 @ 2024-08-06 14:15:44
@[makeway](/user/1413309)
```
#include<bits/stdc++.h>
using namespace std;
double x;
int main(){
cin>>x;
cout<<ceil(log(1-x/100)/log(0.98));
return 0;
}
```
by ny_123457 @ 2024-08-06 14:15:44
好像可以递推。。。
by ny_123457 @ 2024-08-06 14:17:03
@[123457SB](/user/1368090)
貌似是的
by xujiacheng0312 @ 2024-08-06 14:17:48
@[123457SB](/user/1368090) log可是高中知识,现在用不太好吧。
by makeway @ 2024-08-06 14:20:29
老实递推
by ny_123457 @ 2024-08-06 14:21:13
@[makeway](/user/1413309)
你把b改成int
by xujiacheng0312 @ 2024-08-06 14:22:53
```
int main(){
cin>>n;
x=2;
for(int i=1;i<=1000;i++){
x=x*0.98;
if(x>=n){
cout<<i;
return 0;
}
}
return 0;
}
```
by ny_123457 @ 2024-08-06 14:23:18
int不行
by makeway @ 2024-08-06 14:25:20
@[makeway](/user/1413309) 你打的有问题啊。\
你想,a存的是已经游了的总距离,但是实际上要乘0.98的是上一步游的距离,所以会错。\
另拿一个变量存上一步游的距离即可
by mx26 @ 2024-08-06 14:31:31