Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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="";
- if (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){// romb
- 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";
- }
- 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){ //pelny, domknięty trojką
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement