#include <iostream> #include <stdio.h> #include <vector> using namespace std; int k,p; int arr[100]; vector <bool> v; int main() { scanf("%d",&k); while(k){ v.push_back(k&1); k>>=1; } p=100; for(int i=v.size()-2;i>=0;i--){ arr[p-2]=p; p-=2; if(v[i]) arr[p-1]=100; p--; } printf("100\n"); for(int i=1;i<100;i++){ if(arr[i]) printf("%d %d\n",i+1,arr[i]); else printf("%d -1\n",i+1,arr[i]); } printf("-1 -1\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 | #include <iostream> #include <stdio.h> #include <vector> using namespace std; int k,p; int arr[100]; vector <bool> v; int main() { scanf("%d",&k); while(k){ v.push_back(k&1); k>>=1; } p=100; for(int i=v.size()-2;i>=0;i--){ arr[p-2]=p; p-=2; if(v[i]) arr[p-1]=100; p--; } printf("100\n"); for(int i=1;i<100;i++){ if(arr[i]) printf("%d %d\n",i+1,arr[i]); else printf("%d -1\n",i+1,arr[i]); } printf("-1 -1\n"); return 0; } |