알고리즘

C++ 알고리즘 - 백준 9461 파도반 수열

마루설아 2025. 1. 5. 23:31

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

 

#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

int main(void) {
	/************** C++ Init **************/
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	/************** C++ Init **************/


	int input1, input2;
	vector<long long> v;
	
	v.push_back(0);
	v.push_back(1);
	v.push_back(1);
	v.push_back(1);
	v.push_back(2);
	v.push_back(2);
	v.push_back(3);
	v.push_back(4);
	v.push_back(5);
	v.push_back(7);
	v.push_back(9);

	for (int i = 11; i < 101; i++) {
		v.push_back(v[i - 1] + v[i - 5]);
	}

	cin >> input1;

	for (int i = 0; i < input1; i++) {
		cin >> input2;
		cout << v[input2] << endl;
	}
}