钱币兑换问题 hdu1284

钱币兑换问题 

//只需要计算出可以换多少3分的和多少2分的就可以了
#include <stdio.h>
int main ()
{
 int n,s,i;
 while (scanf("%d",&n)!=EOF)
 {
      s=n/3+1;//计算3分的
      for (i=0;i<=n/3;i++)
       s+=(n-3*i)/2;//计算2分的 不过因为已经算过3分的 所以那一部分要先减掉
      printf ("%d\n",s);
 }
 return 0;
}

Problem Description hdu1284

在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法。请你编程序计算出共有多少种兑法。

  

Input

每行只有一个正整数N,N小于32768。  

Output

对应每个输入,输出兑换方法数。

  

Sample Input

2934

12553

  

Sample Output

718831

13137761

posted @ 2011-05-27 21:08  tonyspace  阅读(299)  评论(0编辑  收藏  举报