#include<bits/stdc++.h> typedef long long ll; typedef long double ld; typedef std::pair<ll, ll> pll; typedef std::pair<int, int> pii; #define all(x) (x).begin(),(x).end() #define debug std::cout<<"ok"<<std::endl const ll INF=1e18; main () { std::vector<ll> F(50,1); for (int i=2; i<50; i++) F[i]=F[i-1]+F[i-2]; ll k; std::cin>>k; std::vector<pii> V(81, {-1,-1}); for (int i=0; i<15; i++) { V[i].first=2*i+2; V[i].second=2*i+3; } for (int i=31; i<78; i++) { V[i].first=i+2; V[i].second=i+3; } V[78].first=80; V[79].first=81; for (int i=30; i>14; i--) { if (4*(i-15)+3<50 &&k>=F[4*(i-15)+3]) { V[i].second=79-4*(i-15)-2; k-=F[4*(i-15)+3]; } if (4*(i-15)+2<50 &&k>=F[4*(i-15)+2]) { V[i].second=79-4*(i-15)-1; k-=F[4*(i-15)+2]; } if (4*(i-15)+1<50 && k>=F[4*(i-15)+1]) { V[i].first=79-4*(i-15); k-=F[4*(i-15)+1]; } if (4*(i-15)<50 &&k>=F[4*(i-15)]) { V[i].first=79-4*(i-15)+1; k-=F[4*(i-15)]; } } std::cout<<V.size()<<std::endl; for (auto a:V) std::cout<<a.first<<' '<<a.second<<std::endl; }
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 55 56 57 58 59 | #include<bits/stdc++.h> typedef long long ll; typedef long double ld; typedef std::pair<ll, ll> pll; typedef std::pair<int, int> pii; #define all(x) (x).begin(),(x).end() #define debug std::cout<<"ok"<<std::endl const ll INF=1e18; main () { std::vector<ll> F(50,1); for (int i=2; i<50; i++) F[i]=F[i-1]+F[i-2]; ll k; std::cin>>k; std::vector<pii> V(81, {-1,-1}); for (int i=0; i<15; i++) { V[i].first=2*i+2; V[i].second=2*i+3; } for (int i=31; i<78; i++) { V[i].first=i+2; V[i].second=i+3; } V[78].first=80; V[79].first=81; for (int i=30; i>14; i--) { if (4*(i-15)+3<50 &&k>=F[4*(i-15)+3]) { V[i].second=79-4*(i-15)-2; k-=F[4*(i-15)+3]; } if (4*(i-15)+2<50 &&k>=F[4*(i-15)+2]) { V[i].second=79-4*(i-15)-1; k-=F[4*(i-15)+2]; } if (4*(i-15)+1<50 && k>=F[4*(i-15)+1]) { V[i].first=79-4*(i-15); k-=F[4*(i-15)+1]; } if (4*(i-15)<50 &&k>=F[4*(i-15)]) { V[i].first=79-4*(i-15)+1; k-=F[4*(i-15)]; } } std::cout<<V.size()<<std::endl; for (auto a:V) std::cout<<a.first<<' '<<a.second<<std::endl; } |