[BOJ] 2718 타일 채우기

Time Lapse :NONE

2718.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>
int dp[101] = { 1,1,5,11 };
int main(void) {
int N,n;
scanf("%d", &N);
for (int i = 4; i <= 100; ++i) {
dp[i] = (dp[i - 2]<<2) + dp[i - 1];
for (int j = 3; j <= i; j++)
dp[i] += j & 1 ? (dp[i - j]<<1) : dp[i - j] * 3;
}
while (N--) {
scanf("%d", &n);
printf("%d ", dp[n]);
}
return 0;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/30/PS/BOJ/2718/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.