#import sys #g=open('C:/Users/UW/Documents/trojout.out', 'w') #original_stdout = sys.stdout #sys.stdout = g n=int(input()) def kor(m,k): if m<10: if k==0: print(m,"[FB]",sep="",end="") elif k==1: print(m,"[BD]",sep="",end="") else: print(m,"[DF]",sep="",end="") else: j=m//9 r=m-j*9 print("9[",end="") kor(j,k) print("]",end="") if r>0: kor(r,k) def lin(m,k): if m<10: if k==0: print(m,"D",sep="",end="") elif k==1: print(m,"F",sep="",end="") else: print(m,"B",sep="",end="") else: j=m//9 r=m-j*9 print("9[",end="") lin(j,k) print("]",end="") if r>0: lin(r,k) def pas(m,k): kor(m,k) if k==0: print("F",end="") elif k==1: print("B",end="") else: print("D",end="") lin(m,k) def pros(m,p,k): if p<10: print(p,"[",sep="",end="") pas(m,k) print("]",end="") else: j=p//9 r=p-j*9 print("9[",end="") pros(m,j,k) print("]",end="") if r>0: pros(m,r,k) def hol(m,k): if m==1: if k==0: print("D",end="") elif k==1: print("F",end="") else: print("B",end="") elif m==2: if k==0: print("DFDBD",end="") elif k==1: print("FBFDF",end="") else: print("BDBFB",end="") else: lin(m-1,k) trr(m-2,k) if k==0: print("F",end="") kor(m-2,(k+2)%3) print("D",end="") kor(m-2,(k+1)%3) print("BD",end="") elif k==1: print("B",end="") kor(m-2,(k+2)%3) print("F",end="") kor(m-2,(k+1)%3) print("DF",end="") else: print("D",end="") kor(m-2,(k+2)%3) print("B",end="") kor(m-2,(k+1)%3) print("FB",end="") def trr(m,k): if m==1: if k==0: print("FB",end="") elif k==1: print("BD",end="") else: print("DF",end="") return j=m//2 r=m-j pros(j,r,k) lin(j,(k+1)%3) print("2[",end="") hol(j,(k+2)%3) print("]",end="") if j<r: lin(r-1,k) if k==0: print("B",end="") elif k==1: print("D",end="") else: print("F",end="") kor(r-1,k) #n=10**18 trr(n,0) #print(aa) lin(n,0) #b="".join(aa) #sys.stdout = original_stdout #print(len(b)) #g.close()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | #import sys #g=open('C:/Users/UW/Documents/trojout.out', 'w') #original_stdout = sys.stdout #sys.stdout = g n=int(input()) def kor(m,k): if m<10: if k==0: print(m,"[FB]",sep="",end="") elif k==1: print(m,"[BD]",sep="",end="") else: print(m,"[DF]",sep="",end="") else: j=m//9 r=m-j*9 print("9[",end="") kor(j,k) print("]",end="") if r>0: kor(r,k) def lin(m,k): if m<10: if k==0: print(m,"D",sep="",end="") elif k==1: print(m,"F",sep="",end="") else: print(m,"B",sep="",end="") else: j=m//9 r=m-j*9 print("9[",end="") lin(j,k) print("]",end="") if r>0: lin(r,k) def pas(m,k): kor(m,k) if k==0: print("F",end="") elif k==1: print("B",end="") else: print("D",end="") lin(m,k) def pros(m,p,k): if p<10: print(p,"[",sep="",end="") pas(m,k) print("]",end="") else: j=p//9 r=p-j*9 print("9[",end="") pros(m,j,k) print("]",end="") if r>0: pros(m,r,k) def hol(m,k): if m==1: if k==0: print("D",end="") elif k==1: print("F",end="") else: print("B",end="") elif m==2: if k==0: print("DFDBD",end="") elif k==1: print("FBFDF",end="") else: print("BDBFB",end="") else: lin(m-1,k) trr(m-2,k) if k==0: print("F",end="") kor(m-2,(k+2)%3) print("D",end="") kor(m-2,(k+1)%3) print("BD",end="") elif k==1: print("B",end="") kor(m-2,(k+2)%3) print("F",end="") kor(m-2,(k+1)%3) print("DF",end="") else: print("D",end="") kor(m-2,(k+2)%3) print("B",end="") kor(m-2,(k+1)%3) print("FB",end="") def trr(m,k): if m==1: if k==0: print("FB",end="") elif k==1: print("BD",end="") else: print("DF",end="") return j=m//2 r=m-j pros(j,r,k) lin(j,(k+1)%3) print("2[",end="") hol(j,(k+2)%3) print("]",end="") if j<r: lin(r-1,k) if k==0: print("B",end="") elif k==1: print("D",end="") else: print("F",end="") kor(r-1,k) #n=10**18 trr(n,0) #print(aa) lin(n,0) #b="".join(aa) #sys.stdout = original_stdout #print(len(b)) #g.close() |