# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1039278 | 0npata | Fibonacci representations (CEOI18_fib) | C++17 | 0 ms | 0 KiB |
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;
const int fib(int n) {
if(n == 1) return 1;
if(n == 2) return 2;
return fib(n-1)+fib(n-2);
}
int go(int val, int prev) {
if(val == 0) return 1;
if(prev >= 15||val < 0) return 0;
int sum = 0;
for(int i = prev; i<15; i++) {
sum += go(val-fib(i), i+1);
}
return sum;
}
int main() {
int n;
cin >> n;
vec<int> a(n);
for(int i = 0; i<n; i++) cin >> a[i];
vec<int> p(n);
for(int i = 0; i<n; i++) {
p[i] = fib(a[i]) + i > 0 ? p[i-1] : 0;
}
for(int i = 0; i<n; i++) {
cout << go(p[i]) << ' ';
}
cout << '\n';
}