[BOJ] 9461번 : 파도반 수열

2024. 9. 2. 16:25Algorithm

1. problem : 

https://www.acmicpc.net/problem/9461

 

 

2. solution 1 :

#include <bits/stdc++.h>
using namespace std;
int t; 
long long d[105];
int main(void) {
	ios::sync_with_stdio(0); 
	cin.tie(0); 
	cin >> t; 
	
	d[1] = 1, d[2] = 1, d[3] = 1;
	for (int i = 4; i <= 100; i++) d[i] = d[i - 2] + d[i - 3]; 

	while (t--) {
		int n; 
		cin >> n; 
		cout << d[n] << '\n';
	}
}