现在的位置: 首页 > 综合 > 正文

UVA 357

2012年01月12日 ⁄ 综合 ⁄ 共 544字 ⁄ 字号 评论关闭

/**********************************
 * 日期: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;
}

抱歉!评论已关闭.