[BOJ] 9084번 : 동전

2024. 9. 4. 07:05Algorithm

1. problem : 

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

 

2. solution1  :

#include <bits/stdc++.h>
using namespace std;
int n, m; 
int a[10005];
int d[10005];

int main(void) {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int t;
	cin >> t;
	while (t--) {
		cin >> n; 
		for (int i = 0; i < n; i++) cin >> a[i]; 
		fill(d, d + 10005, 0);
		d[0] = 1; 
		cin >> m; 
		for (int i = 0; i < n; i++) {
			for (int j = a[i]; j <= m; j++) {
				d[j] += d[j - a[i]];
			}
		}
		cout << d[m] << '\n';

	}
}

source code 출처 : https://github.com/encrypted-def/basic-algo-lecture/blob/master/0x10/solutions/9084.cpp

 

basic-algo-lecture/0x10/solutions/9084.cpp at master · encrypted-def/basic-algo-lecture

바킹독의 실전 알고리즘 강의 자료. Contribute to encrypted-def/basic-algo-lecture development by creating an account on GitHub.

github.com

 

'Algorithm' 카테고리의 다른 글

[BOJ] 10942번 : 팰린드롬?  (0) 2024.09.05
[BOJ] 1915번 : 가장 큰 정사각형  (0) 2024.09.04
[BOJ] 1699번 : 제곱수의 합  (0) 2024.09.03
[BOJ] 9251번 : LCS  (0) 2024.09.03
[BOJ] 10844번 : 쉬운 계단 수  (0) 2024.09.03