-
Notifications
You must be signed in to change notification settings - Fork 0
/
uva00357.cpp
40 lines (35 loc) · 972 Bytes
/
uva00357.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
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <climits>
#include <cmath>
#include <set>
#include <bitset>
#include <sstream>
#include <iomanip>
#define _ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15);
using namespace std;
#define nCoins 5
#define maxValue 30000
/* Easy problem: complete pack problem. */
int main(){ _
int coins[nCoins] = {1, 5, 10, 25, 50};
vector<long long> table(maxValue+1, 0);
table[0] = 1;
for(int i = 0; i < nCoins; ++i){
for(int v = coins[i]; v <= maxValue; ++v){
table[v] = table[v] + table[v-coins[i]];
}
}
int n;
while(cin >> n){
if(table[n] == 1)
cout << "There is only 1 way to produce " << n << " cents change." << endl;
else
cout << "There are " << table[n] << " ways to produce " << n << " cents change." << endl;
}
return 0;
}