大神求助20分

P1423 小玉在游泳

@[fanbole](/user/1119861) 所以你代码呢?
by NullPointerExpection @ 2024-06-29 16:29:02


这样即可。 ``` #include<iostream> using namespace std; int main() { double s,ans=1,m=2; cin>>s; for(double i=2;i<s;i=i+m) { m=m*0.98; ans++; } cout<<ans; return 0; } ```
by sutiancheng @ 2024-06-29 16:30:55


不是将距离*0.98……
by sutiancheng @ 2024-06-29 16:31:42


```c #include<bits/stdc++.h> using namespace std; int main(){ double n,b = 2,l = 0; cin>>n; while(n>0){ n-=b; b*=0.98; l++; } cout<<l; return 0; } ```
by libohan356218 @ 2024-06-29 16:32:09


```c #include<bits/stdc++.h> using namespace std; int main(){ double s,d=0,a=2; int i=1; cin>>s; d+=2; while(d<s){ a*=0.98; d+=a; i++; } cout<<i; return 0; } ``` @[NullPointerExpection](/user/1360496)
by fanbole @ 2024-06-29 16:36:59


@[fanbole](/user/1119861) ```c #include<bits/stdc++.h> using namespace std; int main(){ double s,d=0,a=2; int i=0;//i初始为零 cin>>s; while(d<s){ d+=a; i++; a*=0.98;//double类型 } cout<<i; return 0; } ``` 求关
by libohan356218 @ 2024-06-29 16:37:21


@[NullPointerExpection](/user/1360496) 代码评测里可以看到
by libohan356218 @ 2024-06-29 16:38:22


|