#include <bits/stdc++.h> using namespace std; typedef long long ll; #ifdef LOCAL #define debug(...) __VA_ARGS__ #else #define debug(...) {} #endif int main(){ ios_base::sync_with_stdio(0); cin.tie(); cout.tie(); int i = 0; int k; cin>>k; while ((1<<i) <= k) i++; int n = 2*i; cout<<n<<"\n"; int pointer = 0; for (i = 1; i < n-1; i++){ if (i%2){ cout<<i+1<<" "<<i+2<<"\n"; continue; } cout<<i+1<<" "; if ((1<<pointer)&k) cout<<n<<"\n"; else cout<<-1<<"\n"; pointer++; } cout<<-1<<" "; if ((1<<pointer)&k) cout<<n<<"\n"; else cout<<-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 36 | #include <bits/stdc++.h> using namespace std; typedef long long ll; #ifdef LOCAL #define debug(...) __VA_ARGS__ #else #define debug(...) {} #endif int main(){ ios_base::sync_with_stdio(0); cin.tie(); cout.tie(); int i = 0; int k; cin>>k; while ((1<<i) <= k) i++; int n = 2*i; cout<<n<<"\n"; int pointer = 0; for (i = 1; i < n-1; i++){ if (i%2){ cout<<i+1<<" "<<i+2<<"\n"; continue; } cout<<i+1<<" "; if ((1<<pointer)&k) cout<<n<<"\n"; else cout<<-1<<"\n"; pointer++; } cout<<-1<<" "; if ((1<<pointer)&k) cout<<n<<"\n"; else cout<<-1<<"\n"; cout<<-1<<" "<<-1<<"\n"; return 0; } |