#include<bits/stdc++.h> #define int long long using namespace std; inline int read() { int n=0,f=1,ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { n=n*10+ch-'0'; ch=getchar(); } return n*f; } string xunhuan(string s,int n) { if(n==0)return ""; if(n==1)return s; if(n<=9) { string ans; char k=n+'0'; ans+=k; if(s.length()>1)ans+="["; ans+=s; if(s.length()>1)ans+="]"; return ans; } return "9["+xunhuan(s,n/9)+"]"+xunhuan(s,n%9); } string solve(int n) { if(n==1) { string s="B"; return s; } if(n==2) { string s="BDBFB"; return s; } string s=xunhuan(solve((n-1)/2),2); if(n%2==1) { s+=xunhuan("CE",n-1); string sth=xunhuan("AE",(n-1)/2)+"A"+xunhuan("C",(n-1)/2); s+=xunhuan(sth,(n-1)/2); s+=xunhuan("A",(n-1)/2); s+="B"; return s; } else { s+="B"; s+=xunhuan("CE",n-1); string sth=xunhuan("AE",n/2)+"A"+xunhuan("C",n/2); s+=xunhuan(sth,n/2-1); s+=xunhuan("AFDB",n/2-1); s+="AB"; return s; } } signed main() { int n; n=read(); string ans=solve(n); ans+=xunhuan("D",n)+xunhuan("F",n); cout<<ans<<endl; }
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 | #include<bits/stdc++.h> #define int long long using namespace std; inline int read() { int n=0,f=1,ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { n=n*10+ch-'0'; ch=getchar(); } return n*f; } string xunhuan(string s,int n) { if(n==0)return ""; if(n==1)return s; if(n<=9) { string ans; char k=n+'0'; ans+=k; if(s.length()>1)ans+="["; ans+=s; if(s.length()>1)ans+="]"; return ans; } return "9["+xunhuan(s,n/9)+"]"+xunhuan(s,n%9); } string solve(int n) { if(n==1) { string s="B"; return s; } if(n==2) { string s="BDBFB"; return s; } string s=xunhuan(solve((n-1)/2),2); if(n%2==1) { s+=xunhuan("CE",n-1); string sth=xunhuan("AE",(n-1)/2)+"A"+xunhuan("C",(n-1)/2); s+=xunhuan(sth,(n-1)/2); s+=xunhuan("A",(n-1)/2); s+="B"; return s; } else { s+="B"; s+=xunhuan("CE",n-1); string sth=xunhuan("AE",n/2)+"A"+xunhuan("C",n/2); s+=xunhuan(sth,n/2-1); s+=xunhuan("AFDB",n/2-1); s+="AB"; return s; } } signed main() { int n; n=read(); string ans=solve(n); ans+=xunhuan("D",n)+xunhuan("F",n); cout<<ans<<endl; } |