Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using ull = unsigned long long;
  5. using ll = long long;
  6. using ld = long double;
  7. using D = long double;
  8. using ii = pair<int, int>;
  9. using vi = vector<int>;
  10. using vii = vector<ii>;
  11. using vll = vector<ll>;
  12. using vs = vector<string>;
  13. using vvi = vector<vi>;
  14.  
  15. #define pb push_back
  16. #define mp make_pair
  17. #define all(x) x.begin(),x.end()
  18. #define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
  19. #define rep(i, x) for(int i = 0; i < (x); i++)
  20. #define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
  21. #define sqrt(x) sqrt(abs(x))
  22. #define y1 y1_1234413
  23. #define j1 j1_235
  24. #define y0 y0_235
  25. #define j0 j0_256
  26. #define fi first
  27. #define se second
  28. #define re return
  29. #define prev PREV
  30. #define next NEXT
  31. #define sz(x) ((int)x.size())
  32. #define vl v*2
  33. #define vr v*2+1
  34. #define endl "\n"
  35.  
  36. template<typename T> T sqr(T a) { re a * a; }
  37. template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
  38. template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
  39. template<typename T> T abs(T a) { re a > 0 ? a : -a; }
  40.  
  41. const int inf = 2e9;
  42. const ld st = 0.000001;
  43. const ld pi = acos((ld)-1);
  44. const int N = 3e5 + 10;
  45. const D eps = 1e-7;
  46.  
  47. #define FILENAME ""
  48.  
  49. int n;
  50. int m;
  51. D s, p;
  52.  
  53. bool f (D x) {
  54. D cs = s;
  55. for (int i = 0; i < m; i++) {
  56. D pay = x;
  57. pay -= cs * p;
  58. if (pay < -eps) re false;
  59. cs -= pay;
  60. if (cs <= 0) re true;
  61. }
  62. re false;
  63. }
  64.  
  65. D lwb () {
  66. D l = 0;
  67. D r = 2 * s;
  68. for (int i = 0; i < 100; i++) {
  69. D c = (r + l) / 2;
  70. if (f (c)) r = c;
  71. else l = c;
  72. }
  73. re l;
  74. }
  75.  
  76. int main() {
  77. ios::sync_with_stdio(0);
  78. cin.tie(0); cout.tie(0);
  79. //freopen ("input.txt", "r", stdin);
  80. //freopen ("output.txt", "w", stdout);
  81. cin >> s >> m >> p;
  82. p /= 100;
  83. cout << setprecision(9) << lwb ();
  84.  
  85. re 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement