Skip to content

Instantly share code, notes, and snippets.

@YigWoo
Created January 12, 2017 16:14
Show Gist options
  • Save YigWoo/73fa70f520ced83d22392b9bf26c6f91 to your computer and use it in GitHub Desktop.
Save YigWoo/73fa70f520ced83d22392b9bf26c6f91 to your computer and use it in GitHub Desktop.
caseCount = int(input())
def compute_sum(num):
result = 0
for o in str(num):
o = int(o)
result += o
return str(result)
for i in range(caseCount):
lines = int(input())
res = 0
for j in range(lines):
l = input()
x = int(l.split(' ')[0])
y = int(l.split(' ')[1])
res += x * y
while len(str(res)) > 1:
res = compute_sum(res)
print(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment