`

UVA 357

 
阅读更多
/**********************************
*日期:2011-3-7
*作者:SJF
*题号:357
*结果:AC
********************************/
#include<stdio.h>
long long count;
int coin[5]={1,5,10,25,50};
long long ways[100000]={0};
void calculate()
{
int k,i;
ways[0]=1;
for(k=0;k<5;k++)
{
for(i=coin[k];i<=30000;i++)
{
ways[i]=ways[i]+ways[i-coin[k]];
}
}
}
int main()
{
int n;
calculate();
while(scanf("%d",&n)!=EOF)
{
count=ways[n];
if(count==1)
printf("There is only 1 way to produce %d cents change.\n",n);
else
printf("There are %lld ways to produce %d cents change.\n",count,n);
}
return 0;
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics