#include <iostream>
using namespace std;
string n2s(int64_t n){
if (n==1) return "";
else return to_string(n);
}
string repeat(string s,int64_t n){
string res="";
while (n>9){
res+="9["+repeat(s,n/9)+"]";
n=n%9;
}
if (n>0){
if (s.size()>1 && n>1)
res+=n2s(n)+"["+s+"]";
else
res+=n2s(n)+s;
}
return res;
}
void rysuj_R(int64_t n){
string s="";
s = repeat("BF",n-1)+"B" +repeat("D",n);
cout<<repeat(s,n);
}
void rysuj_T1(){
cout<<"B";
}
void rysuj_T2(){
cout<<"BDBFB";
}
void rysuj_T3(){
cout<<"BDBDBFFBDBFB";
}
void fastryga(int64_t n){
cout<<repeat("BF",n);
cout<<"B";
}
void fastryga2(int64_t n){
cout<<repeat("BDBFF",n);
cout<<"BDBFB";
}
//5[BDBFF]BDBFB
void rysuj_T(int64_t n){
switch(n){
case 1: rysuj_T1();
break;
case 2: rysuj_T2();
break;
case 3: rysuj_T3();
break;
default:
int64_t f = 2-(n%2);
int64_t k = (n-f)/2;
cout<<"2[";
rysuj_T(k);
cout<<"]";
cout<<repeat("D",k);
cout<<repeat("F",k);
cout<<repeat("D",k);
rysuj_R(k);
if (f==1)
fastryga(2*k);
else
fastryga2(2*k);
break;
}
}
void rysuj_DT(int64_t n){
rysuj_T(n);
cout<<repeat("D",n);
cout<<repeat("F",n);
}
int main()
{
int64_t n;
cin>>n;
rysuj_DT(n);
cout<<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 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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | #include <iostream> using namespace std; string n2s(int64_t n){ if (n==1) return ""; else return to_string(n); } string repeat(string s,int64_t n){ string res=""; while (n>9){ res+="9["+repeat(s,n/9)+"]"; n=n%9; } if (n>0){ if (s.size()>1 && n>1) res+=n2s(n)+"["+s+"]"; else res+=n2s(n)+s; } return res; } void rysuj_R(int64_t n){ string s=""; s = repeat("BF",n-1)+"B" +repeat("D",n); cout<<repeat(s,n); } void rysuj_T1(){ cout<<"B"; } void rysuj_T2(){ cout<<"BDBFB"; } void rysuj_T3(){ cout<<"BDBDBFFBDBFB"; } void fastryga(int64_t n){ cout<<repeat("BF",n); cout<<"B"; } void fastryga2(int64_t n){ cout<<repeat("BDBFF",n); cout<<"BDBFB"; } //5[BDBFF]BDBFB void rysuj_T(int64_t n){ switch(n){ case 1: rysuj_T1(); break; case 2: rysuj_T2(); break; case 3: rysuj_T3(); break; default: int64_t f = 2-(n%2); int64_t k = (n-f)/2; cout<<"2["; rysuj_T(k); cout<<"]"; cout<<repeat("D",k); cout<<repeat("F",k); cout<<repeat("D",k); rysuj_R(k); if (f==1) fastryga(2*k); else fastryga2(2*k); break; } } void rysuj_DT(int64_t n){ rysuj_T(n); cout<<repeat("D",n); cout<<repeat("F",n); } int main() { int64_t n; cin>>n; rysuj_DT(n); cout<<endl; return 0; } |
English