#include <bits/stdc++.h> using namespace std; int k; int fib[100]; vector<int> v, t[103]; void genFib() { fib[0] = 1; fib[1] = 1; for (int i = 2; i <= 44; i++) { //fib[43] = 701408733 fib[i] = fib[i - 1] + fib[i - 2]; //cout << i << " " << fib[i] << "\n"; } } void findFibRep(int x) { int i = 0; while (fib[i] <= x) { i++; } while (x) { i--; if (fib[i] <= x) { v.push_back(i); x -= fib[i]; } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> k; genFib(); findFibRep(k); /*for (auto el : v) { cout << el << " " << fib[el] << "\n"; }*/ t[99].push_back(100); for (int i = 98; i >= 57; i--) { t[i].push_back(i + 1); t[i].push_back(i + 2); } for (int i = 1; i < v.size(); i++) { t[57 - i].push_back(100 - v[i]); t[57 - i].push_back(100 - v[i - 1]); v[i] = 100 - 57 + i; } t[1].push_back(100 - v[v.size() - 1]); cout << "100\n"; for (int i = 1; i <= 100; i++) { while (t[i].size() < 2) t[i].push_back(-1); cout << t[i][0] << " " << t[i][1] << "\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 55 56 57 58 59 | #include <bits/stdc++.h> using namespace std; int k; int fib[100]; vector<int> v, t[103]; void genFib() { fib[0] = 1; fib[1] = 1; for (int i = 2; i <= 44; i++) { //fib[43] = 701408733 fib[i] = fib[i - 1] + fib[i - 2]; //cout << i << " " << fib[i] << "\n"; } } void findFibRep(int x) { int i = 0; while (fib[i] <= x) { i++; } while (x) { i--; if (fib[i] <= x) { v.push_back(i); x -= fib[i]; } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> k; genFib(); findFibRep(k); /*for (auto el : v) { cout << el << " " << fib[el] << "\n"; }*/ t[99].push_back(100); for (int i = 98; i >= 57; i--) { t[i].push_back(i + 1); t[i].push_back(i + 2); } for (int i = 1; i < v.size(); i++) { t[57 - i].push_back(100 - v[i]); t[57 - i].push_back(100 - v[i - 1]); v[i] = 100 - 57 + i; } t[1].push_back(100 - v[v.size() - 1]); cout << "100\n"; for (int i = 1; i <= 100; i++) { while (t[i].size() < 2) t[i].push_back(-1); cout << t[i][0] << " " << t[i][1] << "\n"; } return 0; } |