1 #include <iostream> 2 #include <sstream> 3 #include <string> 4 #include <algorithm> 5 #include <vector> 6 using namespace std; 7 8 #define GI ({int _t; scanf("%d", &_t); _t;}) 9 #define FOR(i, a, b) for (int i=a; i<b; i++) 10 #define REP(i, a) FOR(i, 0, a) 11 template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();} 12 int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;} 13 #define DBG(x) cout << #x << "::" << x << endl; 14 #define DBGV(_v) { FOR(_i, 1, _v.size()) { cout << _v[_i] << "\t";} cout << endl;} 15 16 int main() { 17 vector <int> coins; 18 coins.push_back(1); coins.push_back(5); coins.push_back(10); coins.push_back(25); coins.push_back(50); 19 int value = 30001; 20 vector < long long int > flag (value+1, 0); 21 flag[0] = 1; 22 REP(i, coins.size()) { 23 for (int j = 0; j <= value; j++) { 24 if (j-coins[i] >= 0 && flag[j-coins[i]] != 0) { 25 flag[j] += flag[j-coins[i]]; 26 } 27 } 28 } 29 while (cin >> value) { 30 if (flag[value] == 1) { 31 printf("There is only 1 way to produce %d cents change.\n", value); 32 } 33 else { 34 cout << "There are " << flag[value] << " ways to produce "<< value <<" cents change.\n"; 35 } 36 } 37 return 0; 38 }