Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
ABC027[C].py
import math
N = int(input())
n = N ; depth = 0
while(n>0):
n = n // 2
depth +=1
def solve():
t = 0
x = 1
if depth % 2 == 1:
while(1):
if (2*x + 1 > N and 2*x >N):
return 1 if t % 2 == 1 else -1
t += 1
if t % 2 == 1: x = 2*x + 1
else: x = 2*x
else:
while(1):
if (2*x + 1 > N and 2*x >N):
return 1 if t % 2 == 1 else -1
t +=1
if t % 2 == 1: x = 2*x
else: x = 2*x + 1
if __name__ == '__main__':
ans = solve()
#print("depth",depth)
if ans == 1: print("Takahashi")
else:print("Aoki")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment