Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int c, x, y, z, m, s, f, e, t;
  7. int limit, storage, army, time1, time2, temp1, temp2;
  8. x = 0;
  9. time1 = 0;
  10. time2 = 0;
  11. temp1 = 0;
  12. temp2 = 0;
  13. storage = 0;
  14. army = 0;
  15. cin >> c >> x >> y >> z >> m >> s >> f >> e >> t >> f >> y;
  16. if ((y <= x) and (f <= x)) {
  17. if (c <= x) {
  18. while (storage < c) {
  19. storage = storage + s;
  20. time1 = time1 + m;
  21. if (storage > x) {
  22. storage = x;
  23. }
  24. }
  25. }
  26. if (c > x) {
  27. if (y <= s) {
  28. while (x <= c) {
  29. storage = storage + s;
  30. x = x + z;
  31. storage = storage - y;
  32. time1 = time1 + m;
  33. if (storage > x) {
  34. storage = x;
  35. }
  36. };
  37. while (storage < c) {
  38. storage = storage + s;
  39. time1 = time1 + m;
  40. if (storage > x) {
  41. storage = x;
  42. }
  43. }
  44. }
  45. if (y > s) {
  46. temp1 = y / s;
  47. temp2 = y % s;
  48. if (temp2 > 0) {
  49. temp1 = temp1 + 1;
  50. }
  51. while (x < c) {
  52. storage = storage + s * temp1;
  53. x = x + z;
  54. storage = storage - y;
  55. time1 = time1 + m * temp1;
  56. if (storage > x) {
  57. storage = x;
  58. }
  59. }
  60. while (storage < c) {
  61. storage = storage + s;
  62. time1 = time1 + m;
  63. if (storage > x) {
  64. storage = x;
  65. }
  66. }
  67. }
  68. storage = 0;
  69. temp1 = 0;
  70. temp2 = 0;
  71. if (f <= x) {
  72. while (army <= e) {
  73. storage = storage + s;
  74. time2 = time2 + m;
  75. temp1 = storage / f;
  76. temp2 = temp1 * f;
  77. storage = storage - temp2;
  78. army = army + temp1;
  79. if (storage > x) {
  80. storage = x;
  81. }
  82. }
  83. time2 = time2 + t;
  84. if (f > x) {
  85. while (f > x) {
  86. if (y <= s) {
  87. while (x < c) {
  88. storage = storage + s;
  89. x = x + z;
  90. if (storage > x) {
  91. storage = x;
  92. }
  93. storage = storage - y;
  94. time2 = time2 + m;
  95. }
  96. storage = storage + s;
  97. time2 = time2 + m;
  98. temp1 = storage / f;
  99. temp2 = temp1 * f;
  100. storage = storage - temp2;
  101. army = army + temp1;
  102. if (storage > x) {
  103. storage = x;
  104. }
  105. }
  106. if (y > s) {
  107. temp1 = y / s;
  108. temp2 = y % s;
  109. if (temp2 > 0) {
  110. temp1 = temp1 + 1;
  111. }
  112. while (x < c) {
  113. storage = storage + s * temp1;
  114. x = x + z;
  115. storage = storage - y;
  116. time2 = time2 + m * temp1;
  117. if (storage > x) {
  118. storage = x;
  119. }
  120. }
  121. storage = storage + s;
  122. time2 = time2 + m;
  123. temp1 = storage / f;
  124. temp2 = temp1 * f;
  125. storage = storage - temp2;
  126. army = army + temp1;
  127. if (storage > x) {
  128. storage = x;
  129. }
  130. }
  131. }
  132. }
  133. }
  134. }
  135. else {
  136. cout << "Try again. System error - #1. Contact with developper - KSoft";
  137. }
  138. if (time1 < time2){
  139. cout << time1;
  140. }
  141. else {
  142. cout << time2;
  143. }
  144. return 0;
  145. }
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement