---
# System prepended metadata

title: Problem2-2
tags: [week7, answer]

---

# Problem2-2
###### tags:`week7` `answer`
## Code below is faster way to count times
> [name=Bingju Hsieh]
```python=1
n=int(input())
def F(n):
    f = [1]*(n+1)
    for i in range(3,n+1):
        f[i] = f[i-2] +f[i-1]
    return f

l= F(n)
count = l[n-2]
for i in range(2,n+1):
    count+=l[n+1-i]
print(count)
```

## A simpler one implemented with DP
> [name=Jason Lin]
```python=
n = eval(input())

def fibfib(n):
    fib=[1,1]
    for i in range(2,n):
        fib.append(fib[i-2]+fib[i-1]+1)
    return fib[-1]

print(fibfib(n))
```

## A simple way(without using recursion or list)
> [name=Ling]
```python=
def good(n):
    a=1;b=1;c=0;
    if n == 1 or n == 2:
        return 1
    for i in range(3,n+1):
        c = a+b+1
        a,b = b,c        
    return c
n=int(input()) 
print(good(n))
```
**Maybe not that good.**
~只是不想讓list這麼大(其實好像也不會怎樣)~