Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
T = int(input())
Ns = [int(input()) for _ in range(T)]
A = 1
B = 1
cnt = 1
def check_four(i, keta):
s = str(i)
if s[-keta] == '4':
return True
return False
for N in Ns:
N2 = N
keta = 1
keta2 = 1
A = 1
while N2 > 0:
# i桁目が4ならAを増やす
bl = check_four(N - A, keta2)
if bl:
A += keta
#print(N, A, N-A, bl)
N2 = N2 // 10
keta *= 10
keta2 += 1
B = N - A
print("Case #"+str(cnt)+":", A, B)
cnt += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.