Guest User

hse_olymp_inf_n1

a guest
Oct 7th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. n = int(input())  # кол-во розеток в комнате
  2. m = int(input())  # кол-во электроприборов
  3. a = int(input())  # цена разветвителя. даёт +1 розетку
  4. b = int(input())  # цена мультиплексора. даёт +4 розеток
  5. ans = 0
  6. if m > n:
  7.     c = m - n  # кол-во оставшихся приборов
  8.     if 4 * a <= b:
  9.         ans = c * a
  10.         print(ans)
  11.     else:
  12.         ans += (c // 4) * b
  13.         if (c % 4) * a > b:
  14.             ans += b
  15.             print(ans)
  16.         else:
  17.             ans += (c % 4) * a
  18.             print(ans)
  19. else:
  20.     print(0)
Advertisement
Add Comment
Please, Sign In to add comment