Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- a = int(input())
- b = int(input())
- ok = True
- a1 = a
- while a1 and ok:
- if a1 % 10 >= n:
- ok = False
- a1 //= 10
- if ok:
- a1 = b
- while a1 and ok:
- if a1 % 10 >= n:
- ok = False
- a1 //= 10
- if ok:
- s = [0]
- while a or b:
- d1 = 0
- d2 = 0
- if a:
- d1 = a % 10
- if b:
- d2 = b % 10
- a //= 10
- b //= 10
- if s[0]+d1+d2 >= n:
- s[0] = s[0]+d1+d2-n
- s=[1]+s
- else:
- s[0] = s[0]+d1+d2
- if a or b:
- s=[0]+s
- res = ''
- for x in s:
- res += str(x)
- print(res)
- else:
- print('error')
Advertisement
Add Comment
Please, Sign In to add comment