[TIL] BOJ [10870]피보나치 수5 , [2798]블랙잭

Updated:

[10870] 피보나치 수5

image

image

def fibonacci(num):

    if num == 0:

        return 0

    elif num == 1:

        return 1

    return fibonacci(num-1) + fibonacci(num-2)

n=int(input())

print(fibonacci(n))

[2798] 블랙잭

image

image

N, M = map(int, input().split())

arr = list(map(int, input().split()))

result = 0

for i in range(N):

    for j in range(i+1, N):

        for k in range(j+1, N):

            if arr[i] + arr[j] + arr[k] > M:

                continue

            else:

                result = max(result, arr[i] + arr[j] + arr[k])



print(result)