# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
267146 | peuch | Fibonacci representations (CEOI18_fib) | C++17 | 1 ms | 416 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 MAXN = 1e2 + 10;
int n;
int v[MAXN];
int ans[MAXN];
int fib[MAXN];
void refreshFib();
void bt(int cur, int val);
int main(){
bt(1, 0);
scanf("%d", &n);
int sum = 0;
refreshFib();
for(int i = 1; i <= n; i++){
int aux;
scanf("%d", &aux);
sum += fib[aux];
printf("%d\n", ans[sum]);
}
}
void refreshFib(){
fib[1] = 1;
fib[0] = 1;
for(int i = 2; i <= 12; i++)
fib[i] = fib[i - 1] + fib[i - 2];
}
void bt(int cur, int val){
refreshFib();
if(cur > 12){
ans[val]++;
return;
}
bt(cur + 1, val + fib[cur]);
bt(cur + 1, val);
}
Compilation message (stderr)
# | 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... |