#include<bits/stdc++.h> #define ll long long using namespace std; int adj[100][2]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int k; cin >> k; for(int i = 1; i <= 15; i++) { adj[i][0] = 2*i; adj[i][1] = 2*i+1; } for(int i = 16; i <= 31; i++) { if(k % 2) adj[i][0] = 2*i; k /= 2; if(k % 2) adj[i][1] = 2*i+1; k /= 2; } for(int i = 32; i < 63; i++) { adj[i+1][0] = i; adj[i+1][1] = i+32; adj[i+32][0] = i; } adj[32][0] = 100; cout << 100 << "\n"; for(int i = 1; i <= 100; i++) { for(int j = 0; j < 2; j++) { cout << (adj[i][j] == 0 ? -1 : adj[i][j]) << " "; } cout << "\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 | #include<bits/stdc++.h> #define ll long long using namespace std; int adj[100][2]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int k; cin >> k; for(int i = 1; i <= 15; i++) { adj[i][0] = 2*i; adj[i][1] = 2*i+1; } for(int i = 16; i <= 31; i++) { if(k % 2) adj[i][0] = 2*i; k /= 2; if(k % 2) adj[i][1] = 2*i+1; k /= 2; } for(int i = 32; i < 63; i++) { adj[i+1][0] = i; adj[i+1][1] = i+32; adj[i+32][0] = i; } adj[32][0] = 100; cout << 100 << "\n"; for(int i = 1; i <= 100; i++) { for(int j = 0; j < 2; j++) { cout << (adj[i][j] == 0 ? -1 : adj[i][j]) << " "; } cout << "\n"; } return 0; } |