Submission #1039278

# Submission time Handle Problem Language Result Execution time Memory
1039278 2024-07-30T15:59:54 Z 0npata Fibonacci representations (CEOI18_fib) C++17
Compilation error
0 ms 0 KB
#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';

}

Compilation message

fib.cpp: In function 'int main()':
fib.cpp:24:5: error: 'vec' was not declared in this scope
   24 |     vec<int> a(n);
      |     ^~~
fib.cpp:24:9: error: expected primary-expression before 'int'
   24 |     vec<int> a(n);
      |         ^~~
fib.cpp:26:37: error: 'a' was not declared in this scope
   26 |     for(int i = 0; i<n; i++) cin >> a[i];
      |                                     ^
fib.cpp:28:9: error: expected primary-expression before 'int'
   28 |     vec<int> p(n);
      |         ^~~
fib.cpp:31:9: error: 'p' was not declared in this scope
   31 |         p[i] = fib(a[i]) + i > 0 ? p[i-1] : 0;
      |         ^
fib.cpp:31:20: error: 'a' was not declared in this scope
   31 |         p[i] = fib(a[i]) + i > 0 ? p[i-1] : 0;
      |                    ^
fib.cpp:36:20: error: 'p' was not declared in this scope
   36 |         cout << go(p[i]) << ' ';
      |                    ^