Advertisement
Korotkodul

ИТМО N5

Apr 14th, 2022 (edited)
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 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\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.  
  44. vector <vector <int> > f(int N){
  45. vector <vector <int> > mas(4, vector <int>(4,0));
  46. int k = 1;
  47. while (N > 0){
  48. cout<<"N = "<<N<<"\n";
  49. cout<<"N%16 = "<<N%16<<"\n";
  50. cout<<"N%16%4 = "<<N%16%4<<" N%16/4 = "<<N%16/4<<"\n";
  51. cout<<"k = "<<k<<"\n";
  52.  
  53. mas[N%16%4][N%16/4]=k;
  54. //cvv(mas);
  55. k++;
  56. N/=16;
  57.  
  58. }
  59. return mas;
  60. }
  61.  
  62.  
  63. vector <int> to(int x,int bs){
  64. vector <int> r={};
  65. while (x>0){
  66. r.push_back(x%bs);
  67. x/=bs;
  68. }
  69. while (r.size()<4){
  70. r.push_back(0);
  71. }
  72. reverse(r.begin(), r.end());
  73. return r;
  74. }
  75.  
  76.  
  77. vector<int> a= {7, 1, 13, 15},b= {5, 6, 11, 10},c= {14, 2, 16, 9},d= {8, 4, 12, 3};
  78.  
  79.  
  80. vector <vector <int> > goal = {a,b,c,d};
  81.  
  82. int main()
  83. {
  84. ios::sync_with_stdio(0);
  85. cin.tie(0);
  86. cout.tie(0);
  87. //cvv(goal);
  88. vector <pii> v = {{2,2}, {0,3}, {2,0}, {0,2}, {3,2}, {1,2}, {1,3}, {2,3}, {3,0}, {0,0}, {1,1}, {1,0}, {3,1},{3,3}, {2,1}, {0,1} } ;
  89. reverse(v.begin(), v.end());
  90. vector <int> res={};
  91. for (int i =0;i<16;++i){
  92. int nm = v[i].first + 4 * v[i].second;
  93. auto p = to(nm, 2);
  94. for (int j: p){
  95. res.push_back(j);
  96. }
  97. }
  98. cv(res);
  99. reverse(res.begin(), res.end());
  100. int cnt=0;
  101. for (int i = 0; i < res.size();++i){
  102. if (i%3==0){
  103. cnt+=res[i];
  104. }
  105. }
  106. cout<<cnt;
  107. }
  108.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement