Advertisement
Korotkodul

ИТМО 17-18 1

Sep 17th, 2022 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <queue>
  5. #include <algorithm>
  6. #include <string>
  7. #include <stack>
  8. #include <set>
  9. #include <map>
  10. #define pii pair <int,int>
  11. #define vec vector
  12. using namespace std;
  13. using ll = long long;
  14. using ld = long double;
  15. using db = double;
  16. void cv(vector <int> &v){
  17.     for (auto x: v) cout<<x<<' ';
  18.     cout<<"\n";
  19. }
  20.  
  21. void cvl(vector <ll> &v){
  22.     for (auto x: v) cout<<x<<' ';
  23.     cout<<"\n";
  24. }
  25.  
  26.  
  27. void cvv(vector <vector <int> > &v){
  28.     for (auto x: v) cv(x);
  29.     cout<<"\n";
  30. }
  31.  
  32. void cvb(vector <bool> v){
  33.     for (bool x: v) cout<<x<<' ';
  34.     cout<<"\n";
  35. }
  36.  
  37. void cvs(vector <string>  v){
  38.     for (auto a: v){
  39.         cout<<a<<"\n";
  40.     }
  41. }
  42.  
  43. void cvp(vector <pii> a){
  44.     for (auto p: a){
  45.         cout<<p.first<<' '<<p.second<<"\n";
  46.     }
  47.     cout<<"\n";
  48. }
  49.  
  50. int from(vector <int> v, int bs){
  51.     int r=0;
  52.     for (int i=0;i<v.size();++i){
  53.         r += pow(bs,i) * v[i];
  54.     }
  55.     return r;
  56. }
  57.  
  58. vector <int> to(int x, int bs){
  59.     vector <int> v;
  60.     while (x > 0){
  61.         v.push_back(x % bs);
  62.         x /= bs;
  63.     }
  64.     return v;
  65. }
  66.  
  67. bool sh=0;
  68.  
  69.  
  70. bool ok(vector <int> v){
  71.     int n = v.size();
  72.     for (int i = 0; i < n; ++i){
  73.         int cnt=0;
  74.         if (v[i] == 1){
  75.             i--;
  76.             while (i+1 < n && v[i + 1] == 1){
  77.                 i++;
  78.                 cnt++;
  79.             }
  80.         }
  81.         if (cnt >= 6){
  82.             return 1;
  83.         }
  84.     }
  85.     return 0;
  86. }
  87.  
  88. int main()
  89. {
  90.     ios::sync_with_stdio(0);
  91.     cin.tie(0);
  92.     cout.tie(0);
  93.     int ans=0;
  94.     for (int x = 1; x < 16; ++x){
  95.         for (int y = 0; y <= x; ++y){
  96.             for (int z = 0; z <= y; ++z){
  97.                 bool can=1;
  98.                 vector <int> v = {z,y,x};
  99.                 if (sh){
  100.                     cout<<"x y z = "<<x<<' '<<y<<' '<<z<<"\n";
  101.                 }
  102.                 do {
  103.                     vector <int> conv = to(v[0]*16*16 + v[1] * 16 + v[2], 2);
  104.                     if (sh){
  105.                         cout<<"v\n";
  106.                         cv(v);
  107.                         cout<<"conv\n";
  108.                         cv(conv);
  109.                     }
  110.                     if (!ok(conv)){
  111.                         if (sh){
  112.                             cout<<"BAD\n";
  113.                         }
  114.                         can=0;
  115.                         break;
  116.                     }
  117.                 } while (next_permutation(v.begin(), v.end()));
  118.                 if (can) {
  119.                         if (sh) cout<<"GOOD\n";
  120.                         ans++;
  121.                         cv(v);
  122.                         vector <int> conv = to(v[2]*16*16 + v[1] * 16 + v[0], 2);
  123.                         cv(conv);
  124.                 }
  125.                 if (sh) cout<<"\n";
  126.             }
  127.         }
  128.     }
  129.     cout<<ans;
  130. }
  131.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement