#include <bits/stdc++.h> using namespace std; const int D = 100; int kraw[107][2]; void Graf() { int k, v, i; cin >> k; v = 1; for(i = 1; i <= D; ++i) { kraw[i][0] = -1; kraw[i][1] = -1; } if(k % 2 == 1) { kraw[v][1] = D; kraw[v][0] = v + 1; ++v; } k /= 2; while(k > 0) { //cout << k << "\n"; kraw[v][0] = v + 1; kraw[v][1] = v + 2; kraw[v + 1][0] = v + 3; kraw[v + 2][0] = v + 3; if(k % 2 == 1) { kraw[v + 1][1] = D; kraw[v + 2][1] = D; } v += 3; k /= 2; } cout << D << "\n"; for(i = 1; i <= D; ++i) { cout << kraw[i][0] << " " << kraw[i][1] << "\n"; } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); Graf(); 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 | #include <bits/stdc++.h> using namespace std; const int D = 100; int kraw[107][2]; void Graf() { int k, v, i; cin >> k; v = 1; for(i = 1; i <= D; ++i) { kraw[i][0] = -1; kraw[i][1] = -1; } if(k % 2 == 1) { kraw[v][1] = D; kraw[v][0] = v + 1; ++v; } k /= 2; while(k > 0) { //cout << k << "\n"; kraw[v][0] = v + 1; kraw[v][1] = v + 2; kraw[v + 1][0] = v + 3; kraw[v + 2][0] = v + 3; if(k % 2 == 1) { kraw[v + 1][1] = D; kraw[v + 2][1] = D; } v += 3; k /= 2; } cout << D << "\n"; for(i = 1; i <= D; ++i) { cout << kraw[i][0] << " " << kraw[i][1] << "\n"; } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); Graf(); return 0; } |