Advertisement
double_trouble

tupoe_govno

Feb 28th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <cstdio>
  4. #include <vector>
  5. #include <cmath>
  6. #include <string>
  7. #include <algorithm>
  8. #include <string>
  9. #include <deque>
  10. #include <iomanip>
  11. #include <cstddef>
  12.  
  13. #define F first
  14. #define S second
  15.  
  16. using namespace std;
  17.  
  18.  
  19. const long double eps = 0.000000005;
  20. const long double pi = 3.1415926535897932;
  21. const long long inf = 1e9;
  22.  
  23. deque<int> a;
  24.  
  25. int main()
  26. {
  27.     ios_base::sync_with_stdio(0);
  28.     //freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
  29.     // freopen("slalom.in", "r", stdin);freopen("slalom.out", "w", stdout);
  30.  
  31.     int n;
  32.     cin >> n;
  33.  
  34.     for (int i = 0; i < n; i++)
  35.         a.push_back(1);
  36.  
  37.     int ans = 0;
  38.  
  39.     while (a.size() > 1)
  40.     {
  41.         if (a.front() == 1)
  42.         {
  43.             a.pop_front();
  44.             a.pop_front();
  45.             a.push_back(2);
  46.             a.push_back(3);
  47.         }
  48.         else
  49.             if (a.front() == 2)
  50.             {
  51.                 a.pop_front();
  52.                 a.pop_front();
  53.                 a.push_back(1);
  54.             }
  55.             else
  56.             {
  57.                 a.pop_front();
  58.                 a.pop_front();
  59.                 a.push_back(1);
  60.                 a.push_back(1);
  61.                 a.push_back(1);
  62.             }
  63.         ans++;
  64.     }
  65.  
  66.     cout << ans
  67.  
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement