Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. n = int(input())
  2. if input() == "Маша":
  3.   masha = True
  4. else:
  5.   masha = False
  6.  
  7. steps = []
  8. for i in range(int(input())):
  9.   if masha:
  10.     while n % 3 == 0:
  11.       n = n // 3
  12.     while n % 5 == 0:
  13.       n = n // 5
  14.     n += 7
  15.   else:
  16.     n *= 11
  17.     n -= 8
  18.   steps.append(n)
  19.   masha = not masha
  20. steps = [str(i) for i in reversed(sorted(steps))]
  21. res = steps[:2]
  22. print(" ".join([str(i) for i in res]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement