Skip to content

Instantly share code, notes, and snippets.

@YigWoo
Created January 12, 2017 16:13
Show Gist options
  • Save YigWoo/f2ecb4685bbc40999532e79ee150a602 to your computer and use it in GitHub Desktop.
Save YigWoo/f2ecb4685bbc40999532e79ee150a602 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