Notice
Recent Posts
Recent Comments
Link
Little Jay
[C++] 백준 9461번 - 파도반 수열 본문
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n;
long long triangle[101];
void init() {
triangle[1] = 1;
triangle[2] = 1;
triangle[3] = 1;
triangle[4] = 2;
triangle[5] = 2;
for (int i = 6; i <= 100; i++) {
triangle[i] = triangle[i - 1] + triangle[i - 5];
}
return;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
init();
cin >> n;
while (n--) {
int x; cin >> x;
cout << triangle[x] << endl;
}
return 0;
}'알고리즘 > BOJ' 카테고리의 다른 글
| [C++]백준 5014번 - 면접에 늦었다 (0) | 2022.03.14 |
|---|---|
| [C++] 백준 11055번 - 가장 큰 증가 부분 수열 (0) | 2022.02.21 |
| [C++] 백준 1236 - 성지키기 (0) | 2022.02.19 |
| [C++] 백준 1076번 - 저항 (0) | 2022.02.18 |
| [C++] 백준 6588번 - 골드바흐 추측 (0) | 2022.02.11 |
Comments