Advertisement
bartekltg

WDP

Dec 14th, 2022 (edited)
730
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.56 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. string n2s(int64_t n){
  6.     if (n==1) return "";
  7.        else return to_string(n);
  8. }
  9.  
  10. string repeat(string s,int64_t n){
  11.     string res="";
  12.     if (n>9){
  13.         res+="9["+repeat(s,n/9)+"]";
  14.         n=n%9;
  15.     }
  16.     if (n>0){
  17.         if (s.size()>1 && n>1)
  18.             res+=n2s(n)+"["+s+"]";
  19.         else
  20.             res+=n2s(n)+s;
  21.     }
  22.  
  23.     return res;
  24. }
  25.  
  26. void rysuj_R(int64_t n){// romb
  27.     string s="";
  28.     s = repeat("BF",n-1)+"B" +repeat("D",n);
  29.     cout<<repeat(s,n);
  30. }
  31.  
  32. void rysuj_T1(){
  33.     cout<<"B";
  34. }
  35.  
  36. void rysuj_T2(){
  37.     cout<<"BDBFB";
  38. }
  39.  
  40. void rysuj_T3(){
  41.      cout<<"BDBDBFFBDBFB";
  42. }
  43.  
  44.  
  45. void fastryga(int64_t n){
  46.     cout<<repeat("BF",n);
  47.     cout<<"B";
  48. }
  49.  
  50. void fastryga2(int64_t n){
  51.     cout<<repeat("BDBFF",n);
  52.     cout<<"BDBFB";
  53. }
  54.  
  55. void rysuj_T(int64_t n){
  56.     switch(n){
  57.     case 1: rysuj_T1();
  58.         break;
  59.     case 2: rysuj_T2();
  60.         break;
  61.     case 3: rysuj_T3();
  62.         break;
  63.     default:
  64.         int64_t f = 2-(n%2);
  65.         int64_t k = (n-f)/2;
  66.  
  67.         cout<<"2[";
  68.         rysuj_T(k);
  69.         cout<<"]";
  70.         cout<<repeat("D",k);
  71.         cout<<repeat("F",k);
  72.         cout<<repeat("D",k);
  73.         rysuj_R(k);
  74.  
  75.         if (f==1)
  76.             fastryga(2*k);
  77.         else
  78.             fastryga2(2*k);
  79.         break;
  80.     }
  81. }
  82.  
  83. void rysuj_DT(int64_t n){ //pelny, domknięty trojką
  84.     rysuj_T(n);
  85.     cout<<repeat("D",n);
  86.     cout<<repeat("F",n);
  87. }
  88.  
  89. int main(){
  90.     int64_t n;
  91.     cin>>n;
  92.     rysuj_DT(n);
  93.     cout<<endl;
  94.     return 0;
  95. }
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement