Skip to content

Instantly share code, notes, and snippets.

@showyou
Created April 7, 2019 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save showyou/8ca90e38ae148ccd51e1c8beee4fc837 to your computer and use it in GitHub Desktop.
Save showyou/8ca90e38ae148ccd51e1c8beee4fc837 to your computer and use it in GitHub Desktop.
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