|
- #include<iostream>
- #include<cmath>
- #include<iomanip>
- using namespace std;
- int n,a,b,k=1;
- typedef double db;
- db x,l,r,m,ans;
- db eps=0.0001;
- db f(db x)
- {
- db s=a;
- for(int i=1; i<=n; i++)
- {
- s*=1+x;
- s-=b;
- }
- return s;
- }
- void ms(db l,db r)
- {
- while(l<r)
- {
- m=(l+r)/2;
- if(f(m)==0||abs(l-r)<=eps){ans=m;return;}
- else if(f(m)<0)l=m;
- else r=m;
- }
- }
- int main()
- {
- cin>>a>>b>>n;
- r=5.0;
- ms(l,r);
- cout<<fixed<<setprecision(1)<<ans*100;
- return 0;
- }
复制代码 |
|