#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; string repeat(const string &s,ll k) { if(k == 0 || !s.size()) return ""; if(k == 1) return s; if(k <= 9) return string(1, k + '0') + (s.size() == 1? s: "[" + s + "]"); return repeat(repeat(s, k / 9), 9) + repeat(s, k % 9); } string getres(ll n) { if(n == 1) { return "A"; } if(n == 2) { return "AEACA"; } ll m = (n - 1) / 2; string s = getres(m); s = repeat(s, 2) + repeat("E", m) + repeat("C", m) + repeat(repeat("E", m) + repeat("AC", m-1) + "A", m) + repeat("E", m) + repeat("AC", 2*m) + "A"; if(2*m+1 < n) { s = s + repeat("E", 2*m+1) + repeat("AC", 2*m+1) + "A"; } return s; } mt19937_64 gen((unsigned long long)new char ^ time(0)); uniform_int_distribution<ll> rnd(1e17, 1e18); int main(void) { ll n = rnd(gen); scanf("%lld",&n); string s = getres(n) + repeat("E", n) + repeat("C", n); // cout << s.size() << endl; cout << s << endl; 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 | #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; string repeat(const string &s,ll k) { if(k == 0 || !s.size()) return ""; if(k == 1) return s; if(k <= 9) return string(1, k + '0') + (s.size() == 1? s: "[" + s + "]"); return repeat(repeat(s, k / 9), 9) + repeat(s, k % 9); } string getres(ll n) { if(n == 1) { return "A"; } if(n == 2) { return "AEACA"; } ll m = (n - 1) / 2; string s = getres(m); s = repeat(s, 2) + repeat("E", m) + repeat("C", m) + repeat(repeat("E", m) + repeat("AC", m-1) + "A", m) + repeat("E", m) + repeat("AC", 2*m) + "A"; if(2*m+1 < n) { s = s + repeat("E", 2*m+1) + repeat("AC", 2*m+1) + "A"; } return s; } mt19937_64 gen((unsigned long long)new char ^ time(0)); uniform_int_distribution<ll> rnd(1e17, 1e18); int main(void) { ll n = rnd(gen); scanf("%lld",&n); string s = getres(n) + repeat("E", n) + repeat("C", n); // cout << s.size() << endl; cout << s << endl; return 0; } |