We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
yeah finding the pivot is important. My solution is similar. I aimed to remove the expensive operation "modulo", here's my solution.
#Python solution without modulo
t = int(input().strip())
for a0 in range(t):
n = int(input().strip())
x = (int(n / 3)) * 3
y = 0
while True:
y = n - x
if ((int(y / 5)) * 5 != y):
if (x == 0):
print("-1")
break
x = (int((x - 1) / 3)) * 3
else:
print (int(x) * "5" + int(y) * "3")
break
Sherlock and The Beast
You are viewing a single comment's thread. Return to all comments →
yeah finding the pivot is important. My solution is similar. I aimed to remove the expensive operation "modulo", here's my solution.