Advertisement
Guest User

...

a guest
Dec 18th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int p, t, x, m;
  9. float e;
  10.  
  11. cin >> p >> t >> x;
  12.  
  13. e = p * 0.436;
  14.  
  15. m = 0;
  16. int taupykleje;
  17. for (int i = 0; i < x; i++) {
  18. int likePinigai = p - e;
  19.  
  20. if (likePinigai >= t) {
  21. taupykleje = t;
  22. likePinigai -= t;
  23. } else {
  24. int pinigaiIkiMax;
  25. pinigaiIkiMax = taupykleje - t;
  26.  
  27. if (likePinigai < pinigaiIkiMax) {
  28. likePinigai = 0;
  29. taupykleje += likePinigai;
  30. } else {
  31. likePinigai -= pinigaiIkiMax;
  32. taupykleje = t;
  33. }
  34. }
  35.  
  36. if (taupykleje == t) {
  37. taupykleje = 0;
  38. m++;
  39. }
  40. }
  41.  
  42. cout << fixed << setprecision(2) << e << endl;
  43. cout << m << endl;
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement