#include<bits/stdc++.h> #define poly vector<int> #define IOS ios::sync_with_stdio(false) #define ll long long #define mp make_pair #define mt make_tuple #define pa pair < int,int > #define fi first #define se second #define inf 1e9 #define mod 998244353 #define int ll // #define N using namespace std; int pw[25]; string rep(string x,int y) { if (!x.size()||y==0) return ""; string res=""; poly g; while (y) { if (y%9!=0) g.push_back(y%9); if (y/9) g.push_back(0); y/=9; } reverse(g.begin(),g.end()); for (auto u:g) { if (u==0) { res="9["+res+"]"; } else { string pre=""; pre+=char('0'+u); pre+="["; pre+=x; pre+="]"; res+=pre; } } // cout<<"?"<<x<<" "<<y<<" "<<res<<'\n'; return res; } string f(int x) { string res=""; if (x==0) return ""; if (x%2==1) { res=f(x-1); res+="F"; res+=rep("DF",x-1); res+=rep("B",x); return res; } else { res+="FB"; // if ((x-2)/2)!=0) res+=rep(f((x-2)/2),2); res+=rep("FD",x-1); res+=rep(rep("B",x-1-(x-2)/2)+rep("DF",x-1-(x-2)/2),(x-2)/2); res+=rep("BD",(x-2)/2); res+=rep("F",x-1); res+=rep("B",x); } return res; } void BellaKira() { int n; cin>>n; string ans=f(n); ans+=rep("D",n); // cout<<ans.size()<<'\n'; cout<<ans<<'\n'; } signed main() { pw[0]=1; for (int i=1;i<=18;i++) pw[i]=pw[i-1]*9; IOS; cin.tie(0); int T=1; while (T--) { BellaKira(); } }
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 | #include<bits/stdc++.h> #define poly vector<int> #define IOS ios::sync_with_stdio(false) #define ll long long #define mp make_pair #define mt make_tuple #define pa pair < int,int > #define fi first #define se second #define inf 1e9 #define mod 998244353 #define int ll // #define N using namespace std; int pw[25]; string rep(string x,int y) { if (!x.size()||y==0) return ""; string res=""; poly g; while (y) { if (y%9!=0) g.push_back(y%9); if (y/9) g.push_back(0); y/=9; } reverse(g.begin(),g.end()); for (auto u:g) { if (u==0) { res="9["+res+"]"; } else { string pre=""; pre+=char('0'+u); pre+="["; pre+=x; pre+="]"; res+=pre; } } // cout<<"?"<<x<<" "<<y<<" "<<res<<'\n'; return res; } string f(int x) { string res=""; if (x==0) return ""; if (x%2==1) { res=f(x-1); res+="F"; res+=rep("DF",x-1); res+=rep("B",x); return res; } else { res+="FB"; // if ((x-2)/2)!=0) res+=rep(f((x-2)/2),2); res+=rep("FD",x-1); res+=rep(rep("B",x-1-(x-2)/2)+rep("DF",x-1-(x-2)/2),(x-2)/2); res+=rep("BD",(x-2)/2); res+=rep("F",x-1); res+=rep("B",x); } return res; } void BellaKira() { int n; cin>>n; string ans=f(n); ans+=rep("D",n); // cout<<ans.size()<<'\n'; cout<<ans<<'\n'; } signed main() { pw[0]=1; for (int i=1;i<=18;i++) pw[i]=pw[i-1]*9; IOS; cin.tie(0); int T=1; while (T--) { BellaKira(); } } |