#include <iostream>
using namespace std;
string d2b(int k)
{
string a="";
while(k)
{
if(k%2==0)
{
a=a+"0";
}
else
{
a=a+"1";
}
k/=2;
}
return a;
}
int potega2(int x)
{
int wynik=1;
for(int i=0;i<x;i++)
{
wynik*=2;
}
return wynik;
}
pair<int,int> tab[102];
int main()
{
int k;
cin>>k;
string a;
a=d2b(k);
for(int i=1;i<=61;i++)
{
if(i%2==1)
{
tab[i].first=i+1;
tab[i].second=i+2;
}
else
{
tab[i].first=i+1;
tab[i].second=-1;
}
}
for(int i=0;i<=a.size();i++)
{
if(a[i]=='1')
{
tab[2*(i+1)].second=64;
}
}
tab[64].first=-1;
tab[64].second=-1;
tab[62].first=-1;
tab[62].second=-1;
tab[63].first=-1;
tab[63].second=-1;
cout<<64<<endl;
for(int i=1;i<=64;i++)
cout<<tab[i].first<<" "<<tab[i].second<<endl;
}
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 69 70 | #include <iostream> using namespace std; string d2b(int k) { string a=""; while(k) { if(k%2==0) { a=a+"0"; } else { a=a+"1"; } k/=2; } return a; } int potega2(int x) { int wynik=1; for(int i=0;i<x;i++) { wynik*=2; } return wynik; } pair<int,int> tab[102]; int main() { int k; cin>>k; string a; a=d2b(k); for(int i=1;i<=61;i++) { if(i%2==1) { tab[i].first=i+1; tab[i].second=i+2; } else { tab[i].first=i+1; tab[i].second=-1; } } for(int i=0;i<=a.size();i++) { if(a[i]=='1') { tab[2*(i+1)].second=64; } } tab[64].first=-1; tab[64].second=-1; tab[62].first=-1; tab[62].second=-1; tab[63].first=-1; tab[63].second=-1; cout<<64<<endl; for(int i=1;i<=64;i++) cout<<tab[i].first<<" "<<tab[i].second<<endl; } |
English