#include<iostream> #define nl "\n" //#include<fstream> //#define cout plik using namespace std; int positions[100]; //fstream plik; void tobin(int n) { int i=0; while(n) { positions[30-i]=n%2; i++; n/=2; } } int n; int main() { //plik.open("dag.txt"); cin>>n; tobin(n); cout<<89<<nl; //cout<<1<<-1<<nl; for(int i=1; i<30; i++) { //cout<<positions[i];} cout<<i+1<<" "; if(positions[i]) { cout<<2*i+29<<nl; } else { cout<<-1<<nl; } } if(positions[30]) { cout<<2*30+29<<" "; } else { cout<<-1<<" "; } cout<<-1<<nl; for(int i=31; i<=87; i++) { cout<<i+1<<" "; if(i%2) { cout<<i+2; } else{ cout<<-1; } cout<<nl; } cout<<89<<" "<<-1<<nl; cout<<-1<<" "<<-1<<nl; /*for(int i=1; i<30; i++) cout<<positions[i]<<" ";*/ 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 62 63 64 65 66 67 68 | #include<iostream> #define nl "\n" //#include<fstream> //#define cout plik using namespace std; int positions[100]; //fstream plik; void tobin(int n) { int i=0; while(n) { positions[30-i]=n%2; i++; n/=2; } } int n; int main() { //plik.open("dag.txt"); cin>>n; tobin(n); cout<<89<<nl; //cout<<1<<-1<<nl; for(int i=1; i<30; i++) { //cout<<positions[i];} cout<<i+1<<" "; if(positions[i]) { cout<<2*i+29<<nl; } else { cout<<-1<<nl; } } if(positions[30]) { cout<<2*30+29<<" "; } else { cout<<-1<<" "; } cout<<-1<<nl; for(int i=31; i<=87; i++) { cout<<i+1<<" "; if(i%2) { cout<<i+2; } else{ cout<<-1; } cout<<nl; } cout<<89<<" "<<-1<<nl; cout<<-1<<" "<<-1<<nl; /*for(int i=1; i<30; i++) cout<<positions[i]<<" ";*/ return 0; } |