#include<bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
vector<int>v{1, 5, 10, 25, 50};
ll coin(ll tk)
{
ll i, j, t[tk+1];
t[0] = 1;
for(i=1;i<=tk;i++)
t[i] = 0;
for(i=0;i<v.size();i++)
{
for(j=v[i];j<=tk;j++)
{
t[j] = t[j] + t[j-v[i]];
}
}
return t[tk];
}
int main()
{
ll n;
while(cin >> n)
{
ll t = coin(n);
if(t == 1)
{
cout << "There is only 1 way to produce " << n << " cents change." << "\n";
}
else
{
cout << "There are " << t << " ways to produce " << n << " cents change." << "\n";
}
}
return 0;
}
#define ll unsigned long long int
using namespace std;
vector<int>v{1, 5, 10, 25, 50};
ll coin(ll tk)
{
ll i, j, t[tk+1];
t[0] = 1;
for(i=1;i<=tk;i++)
t[i] = 0;
for(i=0;i<v.size();i++)
{
for(j=v[i];j<=tk;j++)
{
t[j] = t[j] + t[j-v[i]];
}
}
return t[tk];
}
int main()
{
ll n;
while(cin >> n)
{
ll t = coin(n);
if(t == 1)
{
cout << "There is only 1 way to produce " << n << " cents change." << "\n";
}
else
{
cout << "There are " << t << " ways to produce " << n << " cents change." << "\n";
}
}
return 0;
}
Comments
Post a Comment