#include <bits/stdc++.h> using namespace std; const int N = 100; int k; pair<int, int> kraw[N + 1]; int main() { scanf("%d", &k); for (int i = 1; i < N; i++) { kraw[i].first = i + 1; kraw[i].second = -1; } kraw[N] = {-1, -1}; for (int i = 4; i <= N; i += 3) { if (k == 1) { break; } kraw[i - 2].second = i; if (k % 2 == 1) { kraw[i - 3].second = N; } k /= 2; } printf("%d\n", N); for (int i = 1; i <= N; i++) { printf("%d %d\n", kraw[i].first, kraw[i].second); } }
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 | #include <bits/stdc++.h> using namespace std; const int N = 100; int k; pair<int, int> kraw[N + 1]; int main() { scanf("%d", &k); for (int i = 1; i < N; i++) { kraw[i].first = i + 1; kraw[i].second = -1; } kraw[N] = {-1, -1}; for (int i = 4; i <= N; i += 3) { if (k == 1) { break; } kraw[i - 2].second = i; if (k % 2 == 1) { kraw[i - 3].second = N; } k /= 2; } printf("%d\n", N); for (int i = 1; i <= N; i++) { printf("%d %d\n", kraw[i].first, kraw[i].second); } } |