#include <bits/stdc++.h> using namespace std; int k; int main() { ios_base::sync_with_stdio(0); cin>>k; int g=2; int counter=1; while(g<k){ g*=2; ++counter; } if(k%2==1) --counter; int n=counter*3+1+k%2; cout<<n<<"\n"; if(k%2==1){ cout<<"2 "<<n<<"\n"; } for(int i=0;i<counter;++i){ cout<<i*3+2+k%2<<" "<<i*3+3+k%2<<"\n"; cout<<i*3+4+k%2<<" -1\n"; cout<<i*3+4+k%2<<" -1\n"; } cout<<"-1 -1\n"; }
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 | #include <bits/stdc++.h> using namespace std; int k; int main() { ios_base::sync_with_stdio(0); cin>>k; int g=2; int counter=1; while(g<k){ g*=2; ++counter; } if(k%2==1) --counter; int n=counter*3+1+k%2; cout<<n<<"\n"; if(k%2==1){ cout<<"2 "<<n<<"\n"; } for(int i=0;i<counter;++i){ cout<<i*3+2+k%2<<" "<<i*3+3+k%2<<"\n"; cout<<i*3+4+k%2<<" -1\n"; cout<<i*3+4+k%2<<" -1\n"; } cout<<"-1 -1\n"; } |