#include <iostream> #include <vector> #include <queue> #include <algorithm> using namespace std; typedef long long LL; int n; pair<int, int> t[101]; vector<int> v; int main(){ ios::sync_with_stdio(0); cin>>n; for(int i=1; i<35; i++){ t[i].first = i + 1; t[i].second = -1; } while(n){ v.push_back(n%2); n/=2; } //reverse(v.begin(), v.end()); for(unsigned i=0; i<v.size(); i++){ if(v[i]){ t[i+1].second = 98 - 2*i; } } t[35].first = -1; t[35].second = -1; for(int i=36; i<98; i++){ if(i%2==0){ t[i].first = i+2; t[i].second = i+3; } if(i%2==1){ t[i].first = i+1; t[i].second = i+2; } } t[98].first=100; t[99].first=100; t[100].first=-1; t[98].second=-1; t[99].second=-1; t[100].second=-1; cout<<100<<"\n"; for(int i=1; i<=100; i++){ cout<<t[i].first<<" "<<t[i].second<<"\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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #include <iostream> #include <vector> #include <queue> #include <algorithm> using namespace std; typedef long long LL; int n; pair<int, int> t[101]; vector<int> v; int main(){ ios::sync_with_stdio(0); cin>>n; for(int i=1; i<35; i++){ t[i].first = i + 1; t[i].second = -1; } while(n){ v.push_back(n%2); n/=2; } //reverse(v.begin(), v.end()); for(unsigned i=0; i<v.size(); i++){ if(v[i]){ t[i+1].second = 98 - 2*i; } } t[35].first = -1; t[35].second = -1; for(int i=36; i<98; i++){ if(i%2==0){ t[i].first = i+2; t[i].second = i+3; } if(i%2==1){ t[i].first = i+1; t[i].second = i+2; } } t[98].first=100; t[99].first=100; t[100].first=-1; t[98].second=-1; t[99].second=-1; t[100].second=-1; cout<<100<<"\n"; for(int i=1; i<=100; i++){ cout<<t[i].first<<" "<<t[i].second<<"\n"; } return 0; } |