// // main.cpp // 2022-2-wdp-wersja-dla-profesjonalistow // // Created by Marek on 14/12/2022. // #include <cstdio> #include <string> std::string res; #define ps(X) res += X void repeatstr(long long n, const char *s) { if (n == 0) { return; } if (n == 1) { ps(s); return; } ps("2["); repeatstr(n / 2, s); ps("]"); if (n % 2 == 1) { ps(s); } } void generaterepeatstr(long long n, std::string &res, std::string &s) { if (n == 0) { return; } if (n == 1) { res += s; return; } res += "2["; generaterepeatstr(n / 2, res, s); res += "]"; if (n % 2 == 1) { res += s; } } void drawpara(long long n) { std::string row = ""; std::string r1 = "DB"; generaterepeatstr(n - 1, row, r1); row += "D"; r1 = "F"; generaterepeatstr(n, row, r1); repeatstr(n, row.c_str()); } void tmptrig(long long n) { repeatstr(n, "A"); repeatstr(n, "E"); repeatstr(n, "C"); } void drawtriangle(long long n) { if (n == 0) { return; } if (n == 1) { ps("AEC"); return; } if (n == 2) { ps("F"); drawtriangle(1); ps("BFBDD"); return; } if (n == 3) { ps("F"); drawtriangle(2); ps("2[BF]B3D"); return; } long long small_trig_size = (n - 2) / 2; std::string r1 = "BF"; ps("F2["); //tmptrig(small_trig_size); drawtriangle(small_trig_size); repeatstr(small_trig_size, "BF"); ps("]"); ps("F"); repeatstr(small_trig_size, "E"); ps("C"); drawpara(small_trig_size); ps("F"); if (n % 2 == 1) { ps("F"); repeatstr(n, "B"); repeatstr(n - 1, "DF"); ps("D"); n--; } repeatstr(small_trig_size, "B"); ps("D"); repeatstr(small_trig_size - 1, "E"); repeatstr(small_trig_size - 1, "AC"); ps("B"); repeatstr(small_trig_size - 1, "AC"); ps("ABBDFDB"); repeatstr(n - 1, "D"); } int main(int argc, const char * argv[]) { /*std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);*/ res = ""; long long n; scanf("%lld",&n); drawtriangle(n); printf("%s\n", res.c_str()); 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 125 126 127 128 129 130 | // // main.cpp // 2022-2-wdp-wersja-dla-profesjonalistow // // Created by Marek on 14/12/2022. // #include <cstdio> #include <string> std::string res; #define ps(X) res += X void repeatstr(long long n, const char *s) { if (n == 0) { return; } if (n == 1) { ps(s); return; } ps("2["); repeatstr(n / 2, s); ps("]"); if (n % 2 == 1) { ps(s); } } void generaterepeatstr(long long n, std::string &res, std::string &s) { if (n == 0) { return; } if (n == 1) { res += s; return; } res += "2["; generaterepeatstr(n / 2, res, s); res += "]"; if (n % 2 == 1) { res += s; } } void drawpara(long long n) { std::string row = ""; std::string r1 = "DB"; generaterepeatstr(n - 1, row, r1); row += "D"; r1 = "F"; generaterepeatstr(n, row, r1); repeatstr(n, row.c_str()); } void tmptrig(long long n) { repeatstr(n, "A"); repeatstr(n, "E"); repeatstr(n, "C"); } void drawtriangle(long long n) { if (n == 0) { return; } if (n == 1) { ps("AEC"); return; } if (n == 2) { ps("F"); drawtriangle(1); ps("BFBDD"); return; } if (n == 3) { ps("F"); drawtriangle(2); ps("2[BF]B3D"); return; } long long small_trig_size = (n - 2) / 2; std::string r1 = "BF"; ps("F2["); //tmptrig(small_trig_size); drawtriangle(small_trig_size); repeatstr(small_trig_size, "BF"); ps("]"); ps("F"); repeatstr(small_trig_size, "E"); ps("C"); drawpara(small_trig_size); ps("F"); if (n % 2 == 1) { ps("F"); repeatstr(n, "B"); repeatstr(n - 1, "DF"); ps("D"); n--; } repeatstr(small_trig_size, "B"); ps("D"); repeatstr(small_trig_size - 1, "E"); repeatstr(small_trig_size - 1, "AC"); ps("B"); repeatstr(small_trig_size - 1, "AC"); ps("ABBDFDB"); repeatstr(n - 1, "D"); } int main(int argc, const char * argv[]) { /*std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);*/ res = ""; long long n; scanf("%lld",&n); drawtriangle(n); printf("%s\n", res.c_str()); return 0; } |