#include<iostream> void draw_fl(long long n){ if( n%9 > 1 ) std::cout << n%9 << "F"; else if( n%9 == 1 ) std::cout << "F"; if(n >= 9){ std::cout << "9["; draw_fl(n/9); std::cout << "]"; } } void draw_al(long long n){ if( n%9 > 1 ) std::cout << n%9 << "A"; else if( n%9 == 1 ) std::cout << "A"; if(n >= 9){ std::cout << "9["; draw_al(n/9); std::cout << "]"; } } void draw_el(long long n){ if( n%9 > 1 ) std::cout << n%9 << "E"; else if( n%9 == 1 ) std::cout << "E"; if(n >= 9){ std::cout << "9["; draw_el(n/9); std::cout << "]"; } } void draw_dl(long long n){ if( n%9 > 1 ) std::cout << n%9 << "D"; else if( n%9 == 1 ) std::cout << "D"; if(n >= 9){ std::cout << "9["; draw_dl(n/9); std::cout << "]"; } } void draw_bdl(long long n){ if( n%9 > 1 ) std::cout << n%9 << "[BD]"; else if( n%9 == 1 ) std::cout << "BD"; if(n >= 9){ std::cout << "9["; draw_bdl(n/9); std::cout << "]"; } } void draw_cel(long long n){ if( n%9 > 1 ) std::cout << n%9 << "[CE]"; else if( n%9 == 1 ) std::cout << "CE"; if(n >= 9){ std::cout << "9["; draw_cel(n/9); std::cout << "]"; } } void draw_trp_l(long long n){ draw_fl(n); draw_bdl(n-1); std::cout << "B"; } void draw_trp(long long n, long long m){ if( n%9 > 1 ){ std::cout << n%9 << "["; draw_trp_l(m); std::cout << "]"; }else if( n%9 == 1 ){ draw_trp_l(m); } if(n >= 9){ std::cout << "9["; draw_trp(n/9, m); std::cout << "]"; } } void draw_tr(long long n){ if(n == 0) return; long long s = (n-1)/2; if(s>0){ std::cout << "2["; draw_tr(s); std::cout << "]"; draw_cel(2*s); draw_trp(s,s); draw_dl(s); } std::cout << "C"; draw_al(2*s+1); if( n%2 == 0 ){ draw_cel(2*s+1); std::cout << "C"; draw_al(2*s+2); } } int main(){ std::ios_base::sync_with_stdio(0); std::cin.tie(0); long long n; std::cin >> n; draw_tr(n); draw_el(n); return 0; }
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 | #include<iostream> void draw_fl(long long n){ if( n%9 > 1 ) std::cout << n%9 << "F"; else if( n%9 == 1 ) std::cout << "F"; if(n >= 9){ std::cout << "9["; draw_fl(n/9); std::cout << "]"; } } void draw_al(long long n){ if( n%9 > 1 ) std::cout << n%9 << "A"; else if( n%9 == 1 ) std::cout << "A"; if(n >= 9){ std::cout << "9["; draw_al(n/9); std::cout << "]"; } } void draw_el(long long n){ if( n%9 > 1 ) std::cout << n%9 << "E"; else if( n%9 == 1 ) std::cout << "E"; if(n >= 9){ std::cout << "9["; draw_el(n/9); std::cout << "]"; } } void draw_dl(long long n){ if( n%9 > 1 ) std::cout << n%9 << "D"; else if( n%9 == 1 ) std::cout << "D"; if(n >= 9){ std::cout << "9["; draw_dl(n/9); std::cout << "]"; } } void draw_bdl(long long n){ if( n%9 > 1 ) std::cout << n%9 << "[BD]"; else if( n%9 == 1 ) std::cout << "BD"; if(n >= 9){ std::cout << "9["; draw_bdl(n/9); std::cout << "]"; } } void draw_cel(long long n){ if( n%9 > 1 ) std::cout << n%9 << "[CE]"; else if( n%9 == 1 ) std::cout << "CE"; if(n >= 9){ std::cout << "9["; draw_cel(n/9); std::cout << "]"; } } void draw_trp_l(long long n){ draw_fl(n); draw_bdl(n-1); std::cout << "B"; } void draw_trp(long long n, long long m){ if( n%9 > 1 ){ std::cout << n%9 << "["; draw_trp_l(m); std::cout << "]"; }else if( n%9 == 1 ){ draw_trp_l(m); } if(n >= 9){ std::cout << "9["; draw_trp(n/9, m); std::cout << "]"; } } void draw_tr(long long n){ if(n == 0) return; long long s = (n-1)/2; if(s>0){ std::cout << "2["; draw_tr(s); std::cout << "]"; draw_cel(2*s); draw_trp(s,s); draw_dl(s); } std::cout << "C"; draw_al(2*s+1); if( n%2 == 0 ){ draw_cel(2*s+1); std::cout << "C"; draw_al(2*s+2); } } int main(){ std::ios_base::sync_with_stdio(0); std::cin.tie(0); long long n; std::cin >> n; draw_tr(n); draw_el(n); return 0; } |