This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |