#include <cstdio> #include <vector> using namespace std; int main() { int k; scanf("%d", &k); vector<int> v; while (k > 1) { v.push_back(k % 2); k >>= 1; } int n = v.size() * 2 + 2; printf("%d\n", n); for (int i=0; i<v.size(); ++i) { printf("%d %d\n", 2 * i + 2, 2 * i + 3); int extra = v[i] * (n + 1) - 1; printf("%d %d\n", 2 * i + 3, extra); } printf("%d -1\n", n); printf("-1 -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 | #include <cstdio> #include <vector> using namespace std; int main() { int k; scanf("%d", &k); vector<int> v; while (k > 1) { v.push_back(k % 2); k >>= 1; } int n = v.size() * 2 + 2; printf("%d\n", n); for (int i=0; i<v.size(); ++i) { printf("%d %d\n", 2 * i + 2, 2 * i + 3); int extra = v[i] * (n + 1) - 1; printf("%d %d\n", 2 * i + 3, extra); } printf("%d -1\n", n); printf("-1 -1\n"); return 0; } |