#include <iostream> using namespace std; int lcyfr=0, k; bool cyfry[33]; int main() { ios_base::sync_with_stdio(0); cin >> k; while(k>0) { cyfry[lcyfr]=k%2; k/=2; lcyfr++; } cout << 3*lcyfr+1 << "\n"; for(int i=0; i<lcyfr; i++) { cout << 3*i+2 << " " << 3*i+3 << "\n" <<3*(i+1)+1 << " "; if(cyfry[i]&&i!=lcyfr-1) cout << 3*lcyfr+1 << "\n"; else cout << -1 <<"\n"; cout << 3*(i+1)+1 << " " << -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 | #include <iostream> using namespace std; int lcyfr=0, k; bool cyfry[33]; int main() { ios_base::sync_with_stdio(0); cin >> k; while(k>0) { cyfry[lcyfr]=k%2; k/=2; lcyfr++; } cout << 3*lcyfr+1 << "\n"; for(int i=0; i<lcyfr; i++) { cout << 3*i+2 << " " << 3*i+3 << "\n" <<3*(i+1)+1 << " "; if(cyfry[i]&&i!=lcyfr-1) cout << 3*lcyfr+1 << "\n"; else cout << -1 <<"\n"; cout << 3*(i+1)+1 << " " << -1 << "\n"; } cout << -1 << " " << -1 << "\n"; return 0; } |