//Ada Kołodziejczak //Zadanie Skierowany Graf Acykliczny #include <bits/stdc++.h> #define pb push_back using namespace std; int k, i, j; int t[2]; vector <int> v; int main() { ios_base::sync_with_stdio(0); cin>>k; while(k>0) { v.pb(k%2); ++t[k%2]; k/=2; } cout<<v.size()*2+2<<"\n"; i=1; j=0; while(j<v.size()) { cout<<i+1<<" "<<i+2<<"\n"; cout<<i+2<<" "; if(v[j]==1) { cout<<v.size()*2+2<<"\n"; } else { cout<<-1<<"\n"; } ++j; i+=2; } cout<<-1<<-1<<"\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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | //Ada Kołodziejczak //Zadanie Skierowany Graf Acykliczny #include <bits/stdc++.h> #define pb push_back using namespace std; int k, i, j; int t[2]; vector <int> v; int main() { ios_base::sync_with_stdio(0); cin>>k; while(k>0) { v.pb(k%2); ++t[k%2]; k/=2; } cout<<v.size()*2+2<<"\n"; i=1; j=0; while(j<v.size()) { cout<<i+1<<" "<<i+2<<"\n"; cout<<i+2<<" "; if(v[j]==1) { cout<<v.size()*2+2<<"\n"; } else { cout<<-1<<"\n"; } ++j; i+=2; } cout<<-1<<-1<<"\n"; cout<<-1<<-1<<"\n"; } |