#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; typedef vector<int> VI; const int INF = 1000000009; const LL LINF = 1000000000000000009LL; #define FOR(i, b, e) for (int i = b; i <= e; ++i) #define FORD(i, b, e) for (int i = b; i >= e; --i) #define REP(i, n) FOR (i, 0, n - 1) #define REV(i, n) FORD (i, n - 1, 0) #define PB push_back #define PP pop_back #define MP make_pair #define MT make_tuple #define ST first #define ND second #define SZ(c) (int)(c).size() #define ALL(c) (c).begin(), (c).end() #define UNIQ(c) (c).erase(unique(ALL(c)), (c).end()); // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/hash_policy.hpp> // using namespace __gnu_pbds; // typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; /*find_by_order() order_of_key()*/ template <typename T, typename S> ostream &operator<<(ostream &out, const pair<T, S> &v) { return (out << "(" << v.ST << ", " << v.ND << ")"); } #define DEBUG(s) s #ifdef local_comp #define PRINT(V) cout << "#" << #V << ": " << V << endl; #else #define PRINT(v) #endif const int N = 105; const int M = 30; int tab[N][2]; int k, n; int main() { #ifndef local_comp ios::sync_with_stdio(0); cin.tie(0); #endif REP (i, N) { tab[i][0] = -1; tab[i][1] = -1; } tab[1][0] = 2; tab[1][1] = 3; cin >> k; n = 2 * M; FOR (i, 1, M - 1) { tab[2 * i][0] = 2 * i + 1; if (2 * i + 3 < n) tab[2 * i + 1][0] = 2 * i + 3; if (k & (1 << i)) tab[2 * i][1] = n; } cout << n << "\n"; FOR (i, 1, n) { cout << tab[i][0] << " " << tab[i][1] << "\n"; } return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; typedef vector<int> VI; const int INF = 1000000009; const LL LINF = 1000000000000000009LL; #define FOR(i, b, e) for (int i = b; i <= e; ++i) #define FORD(i, b, e) for (int i = b; i >= e; --i) #define REP(i, n) FOR (i, 0, n - 1) #define REV(i, n) FORD (i, n - 1, 0) #define PB push_back #define PP pop_back #define MP make_pair #define MT make_tuple #define ST first #define ND second #define SZ(c) (int)(c).size() #define ALL(c) (c).begin(), (c).end() #define UNIQ(c) (c).erase(unique(ALL(c)), (c).end()); // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/hash_policy.hpp> // using namespace __gnu_pbds; // typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; /*find_by_order() order_of_key()*/ template <typename T, typename S> ostream &operator<<(ostream &out, const pair<T, S> &v) { return (out << "(" << v.ST << ", " << v.ND << ")"); } #define DEBUG(s) s #ifdef local_comp #define PRINT(V) cout << "#" << #V << ": " << V << endl; #else #define PRINT(v) #endif const int N = 105; const int M = 30; int tab[N][2]; int k, n; int main() { #ifndef local_comp ios::sync_with_stdio(0); cin.tie(0); #endif REP (i, N) { tab[i][0] = -1; tab[i][1] = -1; } tab[1][0] = 2; tab[1][1] = 3; cin >> k; n = 2 * M; FOR (i, 1, M - 1) { tab[2 * i][0] = 2 * i + 1; if (2 * i + 3 < n) tab[2 * i + 1][0] = 2 * i + 3; if (k & (1 << i)) tab[2 * i][1] = n; } cout << n << "\n"; FOR (i, 1, n) { cout << tab[i][0] << " " << tab[i][1] << "\n"; } return 0; } |