def dcmp(n,op): if n<=9: return f'{n}{op}' if n%9==0: return f'9[{dcmp(n//9,op)}]' return f'9[{dcmp(n//9,op)}]{n%9}{op}' def f(x): if x==0: return '' elif x==1: return 'AEC' elif x==2: return 'AAECEAECC' elif x%2==1: return f'{dcmp(x,"F")}{dcmp(x-1,"[BD]")}B{f(x-1)}D' else: s=f'[{dcmp(x//2,"[CA]")}C{dcmp(x//2,"E")}]' return f'2[A{f(x//2-2)}{dcmp(x//2-1,"[EA]")}{dcmp(x//2-1,"[CA]")}]{dcmp(x,"E")}{dcmp(x//2,s)}{dcmp(x//2,"C")}' print(f(int(input())))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | def dcmp(n,op): if n<=9: return f'{n}{op}' if n%9==0: return f'9[{dcmp(n//9,op)}]' return f'9[{dcmp(n//9,op)}]{n%9}{op}' def f(x): if x==0: return '' elif x==1: return 'AEC' elif x==2: return 'AAECEAECC' elif x%2==1: return f'{dcmp(x,"F")}{dcmp(x-1,"[BD]")}B{f(x-1)}D' else: s=f'[{dcmp(x//2,"[CA]")}C{dcmp(x//2,"E")}]' return f'2[A{f(x//2-2)}{dcmp(x//2-1,"[EA]")}{dcmp(x//2-1,"[CA]")}]{dcmp(x,"E")}{dcmp(x//2,s)}{dcmp(x//2,"C")}' print(f(int(input()))) |