#include<bits/stdc++.h> using namespace std; int tab[107]; int main() { for(int i=32;i<=98;i+=2) { tab[i]=i+2; } int k; cin>>k; int z=1; cout<<100<<"\n"; for(int i=30;i>=0;i--) { if(k>=(1<<i)) { tab[z++]=100-(i*2); k-=(1<<i); } } for(int i=1;i<=30;i++) { if(tab[i]==0) { cout<<i+1<<" "<<-1<<"\n"; } else cout<<i+1<<" "<<tab[i]<<"\n"; } cout<<-1<<" "<<-1<<"\n"; cout<<-1<<" "<<-1<<"\n"; for(int i=33;i<=99;i++) { if(tab[i]==0) { cout<<i+1<<" "<<-1<<"\n"; } else cout<<i+1<<" "<<tab[i]<<"\n"; } cout<<-1<<" "<<-1; }
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 | #include<bits/stdc++.h> using namespace std; int tab[107]; int main() { for(int i=32;i<=98;i+=2) { tab[i]=i+2; } int k; cin>>k; int z=1; cout<<100<<"\n"; for(int i=30;i>=0;i--) { if(k>=(1<<i)) { tab[z++]=100-(i*2); k-=(1<<i); } } for(int i=1;i<=30;i++) { if(tab[i]==0) { cout<<i+1<<" "<<-1<<"\n"; } else cout<<i+1<<" "<<tab[i]<<"\n"; } cout<<-1<<" "<<-1<<"\n"; cout<<-1<<" "<<-1<<"\n"; for(int i=33;i<=99;i++) { if(tab[i]==0) { cout<<i+1<<" "<<-1<<"\n"; } else cout<<i+1<<" "<<tab[i]<<"\n"; } cout<<-1<<" "<<-1; } |