문제
코드
#include <string>
#include <vector>
using namespace std;
int memo[100001];
int fibonacci(int n)
{
if( n <= 1)
{
return n;
}
else
{
if(memo[n] > 0)
return memo[n];
memo[n] = (fibonacci(n-1) + fibonacci(n-2)) % 1234567;
return memo[n];
}
}
int solution(int n) {
return fibonacci(n);
}
결과
걸린시간
20분
'개발 > 알고리즘' 카테고리의 다른 글
프로그래머스 JadenCase 문자열 만들기 C++ (0) | 2020.12.23 |
---|---|
프로그래머스 튜플 C++ (0) | 2020.12.22 |
프로그래머스 N개의 최소공배수 (0) | 2020.12.15 |
프로그래머스 멀쩡한 사각형 C++ (0) | 2020.12.15 |
프로그래머스 큰 수 만들기 C++ (0) | 2020.12.13 |