#include <iostream> using namespace std; int main() { int n; cin>>n; if(n==1) { cout<<"2\n2 -1\n-1 -1\n"; return 0; } cout<<n+1<<endl; for(int i=0; i<n+1; i++) { if(n%2==0) { if(i%2==0 && i!=n) cout<<i+2<<" "<<i+3<<endl; else if(i%2==1) cout<<i+2<<" -1"<<endl; else cout<<"-1 -1"<<endl; } else { if(i%2==1 && i!=n) cout<<i+2<<" "<<i+3<<endl; else if(i==0) cout<<i+2<<" "<<n+1<<endl; else if(i%2==0) cout<<i+2<<" -1"<<endl; else cout<<"-1 -1"<<endl; } } 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 37 38 39 40 | #include <iostream> using namespace std; int main() { int n; cin>>n; if(n==1) { cout<<"2\n2 -1\n-1 -1\n"; return 0; } cout<<n+1<<endl; for(int i=0; i<n+1; i++) { if(n%2==0) { if(i%2==0 && i!=n) cout<<i+2<<" "<<i+3<<endl; else if(i%2==1) cout<<i+2<<" -1"<<endl; else cout<<"-1 -1"<<endl; } else { if(i%2==1 && i!=n) cout<<i+2<<" "<<i+3<<endl; else if(i==0) cout<<i+2<<" "<<n+1<<endl; else if(i%2==0) cout<<i+2<<" -1"<<endl; else cout<<"-1 -1"<<endl; } } return 0; } |