문제풀이: 피보나치수 활용해서 풀자!
#include <string>
#include <vector>
using namespace std;
long long solution(int n) {
long long answer = 0;
vector<int>func(n+1);
func[0] = 1;
func[1] = 1;
for (int i = 2; i <= n; i++) {
func[i] = (func[i - 1] + func[i - 2]) % 1234567;
}
answer = func[n];
return answer;
}
'코딩테스트' 카테고리의 다른 글
프로그래머스_0단계_주사위의개수C++ (0) | 2024.04.11 |
---|---|
프로그래머스_0단계_개미군단C++ (0) | 2024.04.11 |
프로그래머스_2단계_피보나치 수C++ (0) | 2024.04.09 |
프로그래머스_1단계_정수 제곱근 판별C++ (0) | 2024.04.09 |
프로그래머스_1단계_ 직사각형 별찍기C++ (0) | 2024.04.09 |