求助!

P1423 小玉在游泳

显然你用 `scanf` 读入浮点数时应该用 `"%lf"` 而不是 `"%d"`。
by ATZdhjeb @ 2023-07-27 18:21:21


还有 `scanf` 读入时要加取址符,也就是那句话要写成 `scanf("%lf",&s);`。
by ATZdhjeb @ 2023-07-27 18:22:35


`cin`and`<iostream>`:那我走?
by Zjc20120331 @ 2023-07-27 18:48:56


@[chenweizhen](/user/676569) (所有)楼上正解
by CSP_juruo @ 2023-07-27 18:51:41


@[ATZdhjeb](/user/483317) @[cut_subject_person](/user/500031) 谢谢二位大佬!
by chenweizhen @ 2023-07-27 18:53:08


@[ATZdhjeb](/user/483317) 可还是TLE?
by chenweizhen @ 2023-07-27 18:54:06


``` #include<cstdio> #include<iostream> #include<cmath> using namespace std; double n,cnt=2,ans=0; int main() { cin>>n; while(n>0) { n-=cnt; cnt=cnt/100*98; ans++; } cout<<ans<<endl; return 0; } ```
by tyy6034 @ 2023-07-27 19:00:42


@[chenweizhen](/user/676569) 循环那部分改成: ```cpp double dis=0,k=2; while(dis<s){ dis+=k; k*=0.98; ans++; } ```
by CSP_juruo @ 2023-07-27 19:03:52


@[cut_subject_person](/user/500031) @[tyy6034](/user/917842) AC了谢谢!
by chenweizhen @ 2023-07-27 19:14:39


|