Submission #467012

#TimeUsernameProblemLanguageResultExecution timeMemory
467012idk321Fibonacci representations (CEOI18_fib)C++17
5 / 100
4067 ms332 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 110; __int128 fib[N]; const int MOD = 1000000007; string num128toint(__int128 num) { string res = ""; while (num > 0) { res += (num % 10) + '0'; num /= 10; } for (int i = 0, j = res.size() - 1; i < j; i++, j--) { swap(res[i], res[j]); } return res; } void calcFib() { for (int i = 3; i < N; i++) { fib[i] = fib[i - 1] + fib[i - 2]; } } int calcFor(__int128 num, int from) { if (num == 0) return 1; if (from <= 0) return 0; int cur = from; while (fib[cur] > num) cur--; int res = calcFor(num - fib[cur], cur - 2); res %= MOD; if (cur > 2) res += calcFor(num - fib[cur], cur - 3); res %= MOD; if (cur > 1) res += calcFor(num - fib[cur - 1], cur - 3); res %= MOD; if (cur > 1 && num >= fib[cur] + fib[cur - 1]) res += calcFor(num - fib[cur] - fib[cur - 1], cur - 2); return res; } int main() { fib[1] = 1; fib[2] = 2; calcFib(); int n; cin >> n; __int128 sum = 0; for (int i = 0; i < n; i++) { int ind; cin >> ind; sum += fib[ind]; cout << calcFor(sum, N - 1) << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...