#include<iostream>
using namespace std;
int main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
long long k,pot=1,ile=0,dodatkowo;
cin>>k;
while(pot<=k)
{
pot*=2;
ile++;
}
pot/=2;
ile--;
cout<<ile*2+2<<"\n";
dodatkowo=k-pot;
for(int i=1;i<ile*2+1;i+=2)
{
cout<<i+1<<" "<<i+2<<"\n";
if(dodatkowo%2==1)
{
cout<<i+2<<" "<<ile*2+2<<"\n";
dodatkowo--;
}
else cout<<i+2<<" -1\n";
dodatkowo/=2;
}
cout<<ile*2+2<<" -1\n";
cout<<"-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 | #include<iostream> using namespace std; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); long long k,pot=1,ile=0,dodatkowo; cin>>k; while(pot<=k) { pot*=2; ile++; } pot/=2; ile--; cout<<ile*2+2<<"\n"; dodatkowo=k-pot; for(int i=1;i<ile*2+1;i+=2) { cout<<i+1<<" "<<i+2<<"\n"; if(dodatkowo%2==1) { cout<<i+2<<" "<<ile*2+2<<"\n"; dodatkowo--; } else cout<<i+2<<" -1\n"; dodatkowo/=2; } cout<<ile*2+2<<" -1\n"; cout<<"-1 -1\n"; return 0; } |
English