Advertisement
NHumme

NUMBERS

Apr 15th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <cmath>
  5. #include <vector>
  6. #include <string>
  7. #include <set>
  8. #include <stack>
  9. #include <queue>
  10. #include <deque>
  11. using namespace std;
  12.  
  13. #define TASK "path"
  14.  
  15. int main() {
  16.  
  17. #ifdef _DEBUG
  18.     freopen("debug.in", "r", stdin);
  19.     freopen("debug.out", "w", stdout);
  20. #else
  21.     //freopen(TASK".in", "r", stdin);
  22.     //freopen(TASK".out", "w", stdout);
  23.     //freopen("input.txt", "r", stdin);
  24.     //freopen("output.txt", "w", stdout);
  25. #endif // _DEBUG
  26.  
  27.     ios_base::sync_with_stdio(0);
  28.     cin.tie(0);
  29.     cout.tie(0);
  30.     cout.precision(6);
  31.  
  32.     int st, n;
  33.     cin >> st >> n;
  34.     vector < int > a, b;
  35.     a.push_back(st);
  36.     for (int k = 0; k < n; k++) {
  37.         for (int i = 0; i < a.size(); i++) {
  38.             cout << a[i] << " ";
  39.         }
  40.         cout << "\n";
  41.         int now = a[0], kol = 1;
  42.         for (int i = 1; i <= a.size(); i++) {
  43.             if (i == a.size() || a[i] != now) {
  44.                 b.push_back(kol);
  45.                 b.push_back(now);
  46.                 if (i != a.size()) {
  47.                     now = a[i], kol = 1;
  48.                 }
  49.                 continue;
  50.             }
  51.             kol++;
  52.         }
  53.         a = b;
  54.         b.clear();
  55.     }
  56.  
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement