Advertisement
double_trouble

misis4_taskA

Feb 25th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.59 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 inf = 1e9;
  22.  
  23. vector<pair<int, int> > ans;
  24.  
  25. int main()
  26. {
  27.     ios_base::sync_with_stdio(0);
  28.     //freopen("bigwall.in", "r", stdin); freopen("bigwall.out", "w", stdout);
  29.     //freopen("input.txt", "r", stdin);
  30.  
  31.     int n;
  32.     cin >> n;
  33.  
  34.     if (n == 1)
  35.     {
  36.         cout << 0 << " " << 0 << endl;
  37.         cout << 0 << endl;
  38.         return 0;
  39.     }
  40.  
  41.     if (n == 2)
  42.     {
  43.         cout << -inf << " " << -inf << endl;
  44.         cout << inf << " " << inf << endl;
  45.         cout << 0 << endl;
  46.         return 0;
  47.     }
  48.  
  49.     int k = (n - 3) / 2 + 1;
  50.  
  51.     cout << -1 << " " << 0 << endl;
  52.     cout << k << " " << 0 << endl;
  53.     cout << 0 << " " << k << endl;
  54.  
  55.     ans.push_back(make_pair(1, 2));
  56.     ans.push_back(make_pair(2, 3));
  57.     ans.push_back(make_pair(1, 3));
  58.  
  59.     pair<int, int> cur = make_pair(0, k);
  60.     pair<int, int> nnew = make_pair(0, 0);
  61.    
  62.     for (int i = 4; i <= n; i++)
  63.     {
  64.         if (cur.S == 0)
  65.         {
  66.             nnew = make_pair(cur.F + 1, k - cur.F - 1);
  67.             ans.push_back(make_pair(i - 1, i));
  68.             cur = nnew;
  69.         }
  70.         else
  71.         {
  72.             nnew = make_pair(cur.F, 0);
  73.             ans.push_back(make_pair(i - 1, i));
  74.             cur = nnew;
  75.         }
  76.  
  77.         cout << cur.F << " " << cur.S << endl;
  78.     }
  79.  
  80.     cout << ans.size() << endl;
  81.     for (int i = 0; i < ans.size(); i++)
  82.         cout << ans[i].first << " " << ans[i].second << endl;
  83.  
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement