Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- double pay(double x,double month,double percent,double total)
- {
- double paid=0;
- for(int i=0;i<month;++i)
- {
- double ai=(percent/100)*(total-paid);
- double bi=x-ai;
- paid+=bi;
- }
- return paid;
- }
- int main()
- {
- double s,m,p;
- cin>>s>>m>>p;
- double up=100*s;
- double down=0;
- while(up-down>1e-7)
- {
- double mid=(up+down)/2;
- double total_p=pay(mid,m,p,s);
- if(total_p>s)
- up=mid;
- else
- down=mid;
- }
- cout<<fixed<<setprecision(6)<<(up+down)/2<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement