#include<iostream> using namespace std; const int MAX_K_BIT = 30; const int n = MAX_K_BIT << 1; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int k; cin >> k; cout << n << "\n"; for(int i = 1; i < MAX_K_BIT; i++) { cout << i+1 << " " << i+MAX_K_BIT << "\n"; } if(k & (1 << (MAX_K_BIT-1))) { cout << n << " -1\n"; } else { cout << "-1 -1\n"; } for(int i = 1; i < MAX_K_BIT; i++) { if(k & (1 << (i-1))) { cout << i+1 << " " << n << "\n"; } else { cout << i+1 << " -1\n"; } } cout << "-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 25 26 27 28 29 30 31 32 33 34 | #include<iostream> using namespace std; const int MAX_K_BIT = 30; const int n = MAX_K_BIT << 1; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int k; cin >> k; cout << n << "\n"; for(int i = 1; i < MAX_K_BIT; i++) { cout << i+1 << " " << i+MAX_K_BIT << "\n"; } if(k & (1 << (MAX_K_BIT-1))) { cout << n << " -1\n"; } else { cout << "-1 -1\n"; } for(int i = 1; i < MAX_K_BIT; i++) { if(k & (1 << (i-1))) { cout << i+1 << " " << n << "\n"; } else { cout << i+1 << " -1\n"; } } cout << "-1 -1\n"; return 0; } |