t = int(input())
global first
for i in range(1, t + 1):
n, group = input(), input()
def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
for l in range(len(group.split())-1):
if group.split()[l] != group.split()[l+1]:
first = gcd(int(group.split()[l]), int(group.split()[l+1]))
break
plist = []
count = 1
plist.append(int(int(group.split()[0]) / first))
plist.append(int(first))
for r in group.split()[1:]:
plist.append(int(int(r) / plist[count]))
count += 1
vlist = sorted(list(set(plist)))
solve = {}
for j in range(len(vlist)):
solve[vlist[j]] = chr(j + 65)
final = ''
for x in plist:
final += solve[x]
print("Case #" + str(i) + ": " + final)
When I test the inputs the code executes the sample set perfectly fine and
I've also created some other inputs to which the code executes perfectly.
However, whenever I submit the attempt, I get a RE. Can someone please
explain what is going wrong? Thanks!
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/7266e7c1-0ff0-4e17-bccd-2fbf12cbcae2%40googlegroups.com.