Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. x = list(input())
  2. y = int(input())
  3. while len(x) >= 10:
  4.     tmp = int("".join(x[:3]))
  5.     if tmp < y:
  6.         tmp = int("".join(x[:4]))
  7.         tmp -= y
  8.         x[0] = str(tmp // 1000)
  9.         tmp = tmp % 1000
  10.         x[1] = str(tmp // 100)
  11.         tmp = tmp % 100
  12.         x[2] = str(tmp // 10)
  13.         tmp = tmp % 10
  14.         x[3] = str(tmp)
  15.     else:
  16.         tmp -= y
  17.         x[0] = str(tmp // 100)
  18.         tmp = tmp % 100
  19.         x[1] = str(tmp // 10)
  20.         tmp = tmp % 10
  21.         x[2] = str(tmp)
  22.     while x[0] == "0":
  23.         x = x[1:]
  24. print(int("".join(x)) % y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement