#include <stdio.h> using namespace std; struct Vertex { int id; int next[2]; }; int main() { Vertex g[100]; for (int i = 0; i < 100; i++) { g[i].id = i; g[i].next[0] = g[i].next[1] = -1; } for (int i = 0; i < 31; i++) { g[i].next[0] = i + 1; g[i+32].next[0] = 32 + i + 1; g[i + 65].next[0] = 32 + i + 1; g[i + 32].next[1] = 65 + i + 1; g[i + 65].next[1] = 65 + i + 1; } // g[93].next[0] = -1; g[96].next[0] = 99; g[63].next[0] = 99; //g[63].next[1] = 99; int k; scanf("%d", &k); for (int i = 31; i >= 0; i--) { if (k % 2 == 1) { g[i].next[1] = 65 + i; } k /= 2; } printf("100\n"); for (int i = 0; i < 100; i++) { if (g[i].next[0] != -1) g[i].next[0]++; if (g[i].next[1] != -1) g[i].next[1]++; printf("%d %d\n", g[i].next[0], g[i].next[1]); } 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | #include <stdio.h> using namespace std; struct Vertex { int id; int next[2]; }; int main() { Vertex g[100]; for (int i = 0; i < 100; i++) { g[i].id = i; g[i].next[0] = g[i].next[1] = -1; } for (int i = 0; i < 31; i++) { g[i].next[0] = i + 1; g[i+32].next[0] = 32 + i + 1; g[i + 65].next[0] = 32 + i + 1; g[i + 32].next[1] = 65 + i + 1; g[i + 65].next[1] = 65 + i + 1; } // g[93].next[0] = -1; g[96].next[0] = 99; g[63].next[0] = 99; //g[63].next[1] = 99; int k; scanf("%d", &k); for (int i = 31; i >= 0; i--) { if (k % 2 == 1) { g[i].next[1] = 65 + i; } k /= 2; } printf("100\n"); for (int i = 0; i < 100; i++) { if (g[i].next[0] != -1) g[i].next[0]++; if (g[i].next[1] != -1) g[i].next[1]++; printf("%d %d\n", g[i].next[0], g[i].next[1]); } return 0; } |