#include<bits/stdc++.h> using namespace std; int32_t main(){ ios::sync_with_stdio(false); int k,n=94; cin >> k; int cur = 1; vector<pair<int,int> > edg(n+1,{-1,-1}); for(int i=1;i<n;i++) edg[i].first = i+1; while(k > 1) { if(k%2 == 1) { edg[cur].second = n; cur++; } edg[cur].second = cur+2; cur += 2; k/=2; } cout<<cur+2<<"\n"; for(int i=1;i<=cur+1;i++) cout<<min(cur+2,edg[i].first)<<" "<<min(cur+2,edg[i].second)<<"\n"; cout<<"-1 -1\n"; }
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 | #include<bits/stdc++.h> using namespace std; int32_t main(){ ios::sync_with_stdio(false); int k,n=94; cin >> k; int cur = 1; vector<pair<int,int> > edg(n+1,{-1,-1}); for(int i=1;i<n;i++) edg[i].first = i+1; while(k > 1) { if(k%2 == 1) { edg[cur].second = n; cur++; } edg[cur].second = cur+2; cur += 2; k/=2; } cout<<cur+2<<"\n"; for(int i=1;i<=cur+1;i++) cout<<min(cur+2,edg[i].first)<<" "<<min(cur+2,edg[i].second)<<"\n"; cout<<"-1 -1\n"; } |