8000 Create 9084.cpp · dkim-coder/basic-algo-lecture@337006d · GitHub
[go: up one dir, main page]

Skip to content

Commit 337006d

Browse files
Create 9084.cpp
1 parent e4c036c commit 337006d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Appendix E/9084.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// http://boj.kr/d50d4f41d3364267bbc1c4bd5821a11d
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
5+
int t, n, m;
6+
int coin[22];
7+
int d[22][10002];
8+
9+
int main(void) {
10+
ios::sync_with_stdio(0);
11+
cin.tie(0);
12+
13+
cin >> t;
14+
while(t--){
15+
cin >> n;
16+
for(int i = 0; i < n; i++){
17+
cin >> coin[i];
18+
d[i][0] = 1;
19+
}
20+
cin >> m;
21+
for(int i = 0; i < n; i++){
22+
for(int j = 1; j <= m; j++){
23+
d[i][j] = 0;
24+
if(i-1 >= 0)
25+
d[i][j] += d[i-1][j];
26+
if(j-coin[i] >= 0)
27+
d[i][j] += d[i][j-coin[i]];
28+
}
29+
}
30+
cout << d[n-1][m] << '\n';
31+
}
32+
}

0 commit comments

Comments
 (0)
0