---
# System prepended metadata

title: 13672 - Fibonacci's soup
tags: [recursion]

---

# 13672 - Fibonacci's soup
>author: Utin
###### tags: `recursion`

---

## Brief
See the code below

## Solution 0

```c=
#include<stdio.h>

int a, b, c, d, n;

//這題必須先宣告，否則會出錯
long long int g();
long long int f();

int main() {
    scanf("%d %d %d %d %d", &a, &b, &c, &d, &n);
    printf("%lld %lld\n", f(n), g(n));
}

long long int f(int i) {
    if(i == 0) return a;
    else if(i == 1) return b;
    else if(i % 2 == 0) return f(i - 1) + g(i / 2);
    else return f(i - 1) + g(i - 2);
}

long long int g(int i) {
    if(i == 0) return c;
    else if(i == 1) return d;
    else if(i % 3 == 0) return g(i - 1) + f(i / 3);
    else return g(i - 1) + f(i - 2);
}
// By Utin
```

## Reference