Algorithm/Problem Solving
2020. 4. 22. 21:13
(공감과 댓글 하나는 글쓴이에게 큰 힘이 됩니다.)
문제 링크
- https://www.acmicpc.net/problem/9461
사용 알고리즘
- DP
풀이
- d[i] = 파도반 수열의 i번째 값
- d[i] = d[i - 2] + d[i - 3]
소스 코드
- https://github.com/moomini/algorithm/blob/master/boj/9461.cpp
#include <cstdio>
long long d[103];
int main(void) {
d[1] = d[2] = d[3] = 1;
for (int i = 4; i <= 100; ++i) d[i] = d[i - 3] + d[i - 2];
int t; for (scanf("%d", &t); t--;) {
int n; scanf("%d", &n);
printf("%lld\n", d[n]);
}
return 0;
}
|
'Algorithm > Problem Solving' 카테고리의 다른 글
[BOJ/2011] 암호코드 (0) | 2020.04.22 |
---|---|
[BOJ/2225] 합분해 (0) | 2020.04.22 |
[BOJ/2133] 타일 채우기 (0) | 2020.04.22 |
[BOJ/1699] 제곱수의 합 (0) | 2020.04.20 |
[BOJ/2579] 계단 오르기 (0) | 2020.04.20 |