#include <bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
string qwq(int cnt,string t)
{
if(cnt==0) return "";
if(cnt==1) return t;
if(cnt<=9)
{
string k;
char c=cnt+'0';
k+=c;
if(t.size()==1) return k+t;
return k+"["+t+"]";
}
return "9["+qwq(cnt/9,t)+"]"+qwq(cnt%9,t);
}
string cons(int n)
{
if(n==1) return "B";
if(n==2) return "BDBFB";
string rtn=qwq(2,cons((n-1)/2));
if(n%2==1)
{
rtn+=qwq(n-1,"CE");
string x=qwq(n/2,"AE")+"A"+qwq(n/2,"C");
rtn+=qwq(n/2,x)+qwq(n/2,"A")+"B";
return rtn;
}
--n;
rtn+=qwq(n-1,"CE");
string x=qwq(n/2,"AE")+"A"+qwq(n/2,"C");
rtn+=qwq(n/2,x)+qwq(n/2,"A")+"B";
++n;
rtn+=qwq(n-1,"D")+qwq(n-1,"BF")+"B";
return rtn;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
string ans=qwq(n,"F")+cons(n)+qwq(n,"D");
// cout << ans.size() << "\n";
cout << ans;
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 | #include <bits/stdc++.h> #define int long long #define mod 1000000007 using namespace std; string qwq(int cnt,string t) { if(cnt==0) return ""; if(cnt==1) return t; if(cnt<=9) { string k; char c=cnt+'0'; k+=c; if(t.size()==1) return k+t; return k+"["+t+"]"; } return "9["+qwq(cnt/9,t)+"]"+qwq(cnt%9,t); } string cons(int n) { if(n==1) return "B"; if(n==2) return "BDBFB"; string rtn=qwq(2,cons((n-1)/2)); if(n%2==1) { rtn+=qwq(n-1,"CE"); string x=qwq(n/2,"AE")+"A"+qwq(n/2,"C"); rtn+=qwq(n/2,x)+qwq(n/2,"A")+"B"; return rtn; } --n; rtn+=qwq(n-1,"CE"); string x=qwq(n/2,"AE")+"A"+qwq(n/2,"C"); rtn+=qwq(n/2,x)+qwq(n/2,"A")+"B"; ++n; rtn+=qwq(n-1,"D")+qwq(n-1,"BF")+"B"; return rtn; } signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string ans=qwq(n,"F")+cons(n)+qwq(n,"D"); // cout << ans.size() << "\n"; cout << ans; return 0; } |
English