#include <iostream>
#include <vector>
using namespace std;
long long k;
vector<bool> isPresent;
int main() {
ios::sync_with_stdio(false);
cin >> k;
while (k > 0) {
isPresent.push_back(k % 2 == 1);
k /= 2;
}
int n = isPresent.size() * 2;
cout << n << endl;
int part = 0;
for (int i = 1; i < n-1; ++i) {
if (i % 2 == 1) {
cout << i + 1 << " " << i + 2 << endl;
} else {
cout << i + 1 << " " << (isPresent[part] ? n : -1) << endl;
part++;
}
}
if (n > 0) {
cout << n << " " << -1 << endl;
cout << -1 << " " << -1 << endl;
}
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 | #include <iostream> #include <vector> using namespace std; long long k; vector<bool> isPresent; int main() { ios::sync_with_stdio(false); cin >> k; while (k > 0) { isPresent.push_back(k % 2 == 1); k /= 2; } int n = isPresent.size() * 2; cout << n << endl; int part = 0; for (int i = 1; i < n-1; ++i) { if (i % 2 == 1) { cout << i + 1 << " " << i + 2 << endl; } else { cout << i + 1 << " " << (isPresent[part] ? n : -1) << endl; part++; } } if (n > 0) { cout << n << " " << -1 << endl; cout << -1 << " " << -1 << endl; } return 0; } |
English