//https://www.acmicpc.net/problem/9461 #include <iostream> | |
using namespace std; | |
long long int p[101]; | |
int main(){ | |
p[1]=p[2]=p[3]=1; | |
p[4]=p[5]=2; | |
p[6]=3; | |
p[7]=4; | |
p[8]=5; | |
p[9]=7; | |
p[10]=9; | |
for(int i=11; i<=100; i++){ | |
p[i]=p[i-1]+p[i-5]; | |
} | |
int t; | |
cin>> t; | |
while(t-->0){ | |
int n; | |
cin>>n; | |
cout <<p[n]<<endl; | |
} | |
return 0; | |
} |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
180522_4963_섬의 개수 (0) | 2018.05.22 |
---|---|
180521_9012_괄호 (0) | 2018.05.21 |
180518_4597_패리티 (0) | 2018.05.18 |
180518_14623_감정이입 (0) | 2018.05.18 |
18505_2751_수 정렬하기 2(합병정렬) (0) | 2018.05.05 |
//https://www.acmicpc.net/problem/9461 #include <iostream> | |
using namespace std; | |
long long int p[101]; | |
int main(){ | |
p[1]=p[2]=p[3]=1; | |
p[4]=p[5]=2; | |
p[6]=3; | |
p[7]=4; | |
p[8]=5; | |
p[9]=7; | |
p[10]=9; | |
for(int i=11; i<=100; i++){ | |
p[i]=p[i-1]+p[i-5]; | |
} | |
int t; | |
cin>> t; | |
while(t-->0){ | |
int n; | |
cin>>n; | |
cout <<p[n]<<endl; | |
} | |
return 0; | |
} |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
180522_4963_섬의 개수 (0) | 2018.05.22 |
---|---|
180521_9012_괄호 (0) | 2018.05.21 |
180518_4597_패리티 (0) | 2018.05.18 |
180518_14623_감정이입 (0) | 2018.05.18 |
18505_2751_수 정렬하기 2(합병정렬) (0) | 2018.05.05 |