This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstring> | |
#define ARRY_RANGE 11 | |
int main(void) | |
{ | |
int d[ARRY_RANGE]; | |
int caseCnt = 0; | |
scanf("%d", &caseCnt); | |
while (caseCnt--) | |
{ | |
memset(d, 0, sizeof(d)); | |
int testCnt = 0; | |
scanf("%d", &testCnt); | |
d[0] = 1; | |
d[1] = 1; | |
d[2] = 2; | |
if(testCnt == 1) | |
{ | |
printf("1\n"); | |
continue; | |
} | |
if(testCnt == 2) | |
{ | |
printf("2\n"); | |
continue; | |
} | |
for (int i = 3; i <= testCnt; i++) | |
{ | |
d[i] = d[i - 1] + d[i - 2] + d[i - 3]; | |
} | |
printf("%d\n", d[testCnt]); | |
} | |
return 0; | |
} |
'문제풀이 > 백준' 카테고리의 다른 글
2309 - 일곱 난쟁이 (0) | 2021.06.22 |
---|---|
16194 - 카드 구매하기 2 (0) | 2021.06.22 |
9095 - 1, 2, 3 더하기 (0) | 2021.06.22 |
1463 - 1로 만들기 (0) | 2021.06.22 |
11052 - 카드 구매하기 (0) | 2021.06.22 |