Last active
March 8, 2017 10:33
-
-
Save fpdjsns/e280f244b56eaab4f921dbe07a209acb to your computer and use it in GitHub Desktop.
CC(Coin Change) 동전 교환
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int main() | |
{ | |
int n, money, cost; | |
int d[11][1000] = { 0 }; | |
cin >> n >> money; | |
d[0][0] = 1; | |
for (int i = 1; i <= n; i++) | |
{ | |
cin >> cost; | |
for (int j = 0; j <= money; j++) | |
{ | |
if (j < cost)//0 ~ j-1 까지는 변함 없음 | |
d[i][j] = d[i - 1][j]; | |
else | |
d[i][j] = d[i][j - cost] + d[i - 1][j]; | |
} | |
} | |
cout << d[n][money]; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment