Coin Exchange Issues Time
limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 6019 accepted Submission (s): 3462
Problem Description in a country with only 1 cents, 2 cents, 3 cents, there are many ways to exchange money n coins. Please write a procedure to figure out how many kinds of methods are in common.
Input is only one positive integer per line n,n less than 32768.
Output corresponds to each input, the number of conversion methods.
Sample Input
2934 12553
Sample Output
718831 13137761
Author Smallbeer (CML)
Source Hangzhou Electronic ACM Team Training Competition (VII)
#include <stdio.h>
#define MAX 32768
int a[35000],c[35000];
int main ()
{
int n,i,j,k;
for (i=0;i<=max;i++)
{
c[i]=1;
a[i]=0;
}
for (i=2;i<=3;i++)
{for (
j=0;j<=max;j++) {for (
k=0;k+j<max;k+=i)
A[k+j]+=c[j] ;
}
for (j=0;j<max;j++)
{
c[j]=a[j];
A[j]=0
}
}
while (scanf ("%d", &n)!=eof)
{
printf ("%d\n", C[n]);
return 0;
}