cgy12306

[백준 BoJ] 9095 - 1, 2, 3 더하기 본문

Algorithm/C++

[백준 BoJ] 9095 - 1, 2, 3 더하기

cgy12306 2021. 3. 25. 16:39
#include<iostream>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, DP[12] ,T;
	cin >> n;
	DP[1] = 1;
	DP[2] = 2;
	DP[3] = 4;
	for (int i = 0; i < n; i++) {
		cin >> T;
		for (int j = 4; j <= T; j++) {
			DP[j] = DP[j - 1] + DP[j - 2] + DP[j - 3];
		}
		cout << DP[T] <<"\n";
	}
	
	
}

'Algorithm > C++' 카테고리의 다른 글

[백준 BoJ] 1463 - 1로 만들기  (0) 2021.03.25
[백준 BoJ] 1260 - DFS와 BFS  (0) 2021.03.25
[백준 BoJ] 1476 - 날짜 계산  (0) 2021.03.25
[백준 BoJ] 1551 - 수열의 변화  (0) 2021.03.25
[백준 BoJ] 1547 - 공  (0) 2021.03.25
Comments