[BOJ] 9461 파도반 수열

Time Lapse :NONE

9561.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <algorithm>
#include <memory.h>
using namespace std;
long long arr[101];
int N,T;

int main(void) {
arr[1]=1;
arr[2]=1;
arr[3]=1;
arr[4]=2;
arr[5]=2;
arr[6]=3;
arr[7]=4;
arr[8]=5;
arr[9]=7;
arr[10]=9;
for(int i=11;i<=100;i++)
arr[i]=arr[i-1]+arr[i-5];

cin>>T;
for(int i=0;i<T;i++)
{
cin>>N;
cout<<arr[N]<<endl;
}
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/30/PS/BOJ/9461/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.