Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define bps 1e-7
- #define eps 1e-8
- using namespace std;
- double s,p;
- int m;
- int mo(double b0){
- double co = s, x = s*p + b0, a, b;
- for(int i = 0; i < m; i++){
- a = co*p;
- b = x - a;
- co -= b;
- }
- if(co < eps) return 1;
- else return -1;
- }
- int main(){
- ios_base::sync_with_stdio(0);
- #ifdef ONLINE_JUDGE
- freopen("input.txt", "rb", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- while(cin >> s >> m >> p){
- p /= 100;
- double lo = 0, hi = s, mi;
- while(hi-lo > bps){
- mi = (lo+hi)/2;
- if(mo(mi) < 0) lo = mi;
- else hi = mi;
- }
- cout << fixed << setprecision(6) << hi + s*p << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement