//GRT_2018 #include <bits/stdc++.h> #define PB push_back #define ST first #define ND second //mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); using namespace std; using ll = long long; using pi = pair<int,int>; using vi = vector<int>; string moves[6] = {"F", "A", "B", "C", "D", "E"}; string repeat(ll cnt, string term) { int rem = cnt % 9; if (cnt == rem) { return to_string(rem) + "[" + term + "]"; } else { string w = "9[" + repeat(cnt / 9, term) + "]"; if (rem > 0) { w += to_string(rem) + "[" + term + "]"; } return w; } } string drawTriangle(ll x, int dir) { if (x == 0) return ""; if (x == 1) { string s = "" + moves[dir]; s += moves[(dir + 4) % 6]; return s; } string s = "2[" + moves[dir]; ll rep = x/2 - 1; if (rep > 0) { s += repeat(rep, moves[(dir+4)%6] + moves[dir]); //s += to_string(rep) + "[" + moves[(dir+4)%6] + moves[dir] + "]"; } s += drawTriangle(x/2-1, (dir+2)%6); s += "]"; string t = ""; string f = "" + moves[(dir+4) % 6]; if (x % 2 == 1) { f = "" + moves[dir] + moves[(dir+4)%6] + moves[(dir+2)%6] + moves[(dir+4)%6]; } s += repeat(x/2, f); //s += to_string(x/2) + "[" + f + "]"; t += repeat(x/2, moves[(dir+3)%6] + moves[(dir+1)%6]); //t += to_string(x/2) + "[" + moves[(dir +3)%6] + moves[(dir+1)%6] + "]"; t += repeat(x/2, moves[(dir + 5) % 6]) + f; //t += to_string(x/2) + "[" + moves[(dir + 5) % 6] + "]" + f; s += repeat(x/2, t); //s += to_string(x/2) + "[" + t + "]"; if (x % 2 == 1) { s += moves[dir] + moves[(dir + 4) % 6]; } return s; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; string ans = drawTriangle(n, 1) + repeat(n, "C"); cout << ans; }
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 | //GRT_2018 #include <bits/stdc++.h> #define PB push_back #define ST first #define ND second //mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); using namespace std; using ll = long long; using pi = pair<int,int>; using vi = vector<int>; string moves[6] = {"F", "A", "B", "C", "D", "E"}; string repeat(ll cnt, string term) { int rem = cnt % 9; if (cnt == rem) { return to_string(rem) + "[" + term + "]"; } else { string w = "9[" + repeat(cnt / 9, term) + "]"; if (rem > 0) { w += to_string(rem) + "[" + term + "]"; } return w; } } string drawTriangle(ll x, int dir) { if (x == 0) return ""; if (x == 1) { string s = "" + moves[dir]; s += moves[(dir + 4) % 6]; return s; } string s = "2[" + moves[dir]; ll rep = x/2 - 1; if (rep > 0) { s += repeat(rep, moves[(dir+4)%6] + moves[dir]); //s += to_string(rep) + "[" + moves[(dir+4)%6] + moves[dir] + "]"; } s += drawTriangle(x/2-1, (dir+2)%6); s += "]"; string t = ""; string f = "" + moves[(dir+4) % 6]; if (x % 2 == 1) { f = "" + moves[dir] + moves[(dir+4)%6] + moves[(dir+2)%6] + moves[(dir+4)%6]; } s += repeat(x/2, f); //s += to_string(x/2) + "[" + f + "]"; t += repeat(x/2, moves[(dir+3)%6] + moves[(dir+1)%6]); //t += to_string(x/2) + "[" + moves[(dir +3)%6] + moves[(dir+1)%6] + "]"; t += repeat(x/2, moves[(dir + 5) % 6]) + f; //t += to_string(x/2) + "[" + moves[(dir + 5) % 6] + "]" + f; s += repeat(x/2, t); //s += to_string(x/2) + "[" + t + "]"; if (x % 2 == 1) { s += moves[dir] + moves[(dir + 4) % 6]; } return s; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; string ans = drawTriangle(n, 1) + repeat(n, "C"); cout << ans; } |