#include <cstdio> #include <iostream> #include <queue> #include <vector> #include <map> #include <set> using namespace std; int main() { int n; cin >> n; int i=1; int v = 1; cout << 100 << endl; if (n > 1) while (n > 1) { if (n%2 == 1) { //cout << i++ << " "; cout << v+1 << " " << 100 << endl; v++; } //else { //cout << i++ << " "; cout << v+1 << " " << v+2 << endl; //cout << i++ << " "; cout << v+2 << " " << -1 << endl; v+=2; } n=(n-n%2)/2; } for (; v<100; v++) { //cout << i++ << " "; cout << "100 -1" << endl; } cout << -1 << " " << -1 << endl; }
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 | #include <cstdio> #include <iostream> #include <queue> #include <vector> #include <map> #include <set> using namespace std; int main() { int n; cin >> n; int i=1; int v = 1; cout << 100 << endl; if (n > 1) while (n > 1) { if (n%2 == 1) { //cout << i++ << " "; cout << v+1 << " " << 100 << endl; v++; } //else { //cout << i++ << " "; cout << v+1 << " " << v+2 << endl; //cout << i++ << " "; cout << v+2 << " " << -1 << endl; v+=2; } n=(n-n%2)/2; } for (; v<100; v++) { //cout << i++ << " "; cout << "100 -1" << endl; } cout << -1 << " " << -1 << endl; } |