Advertisement
Chap4ev

A1 python

Oct 16th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. import math
  2.  
  3. c, x, y, z, m, s, f, e, t = map(int, input().split())
  4. # x = int(input())
  5. # y = int(input())
  6. # print(x//y)
  7.  
  8.  
  9. # набор монет
  10. coins = 0
  11. i_coins = 0  # кол во ходов
  12. storages = 0  # кол во хранилищ
  13. storages_need = math.ceil((c-x)/z)
  14.  
  15. # покупаем хранилища
  16. while storages < storages_need:
  17.     i_coins += 1
  18.     coins += s
  19.     storages_buy = min(storages_need-storages, coins//y)
  20.     coins -= storages_buy*y
  21.     storages += storages_buy
  22.     coins = min(storages*z + x, coins)
  23. i_coins += math.ceil((c-coins)/s)
  24.  
  25. # смэрть
  26. coins = 0
  27. i_war = 0  # кол во ходов
  28. wars = 0
  29.  
  30. while e >= 0:
  31.     i_war += 1
  32.     coins += s
  33.     wars_buy = coins//f
  34.     coins -= wars_buy*f
  35.     e -= wars_buy
  36.  
  37. print(min(i_coins*m, i_war*m + t))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement