Created
January 12, 2017 16:13
-
-
Save YigWoo/f2ecb4685bbc40999532e79ee150a602 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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