hdu1284 (parent function table) __hduoj

Source: Internet
Author: User
Coin Exchange Issues Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 8597 accepted Submission (s): 5169


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)

Ac-code

#include <cstdio>
#include <cstring>
long long c1[40000],c2[40000];
void solve (int n)
{
	long long i,j,k;
	for (i=0;i<=n;i++)
	{
	  c1[i]=1;c2[i]=0;	
	}
	for (i=2;i<=3;i++)
	{for (
	  j=0;j<=n;j++) {for (
		k=0;k+j<=n;k+=i)
		 c2[k+j]+=c1[j];
	  } For	
	  (j=0;j<=n;j++)
	  {
	    c1[j]=c2[j];c2[j]=0;
	  }
    }
return;
}
int main ()
{
    int n,i,j,k;
    Solve (32768);
	while (scanf ("%d", &n)!=eof)
	{
	   printf ("%lld\n", C1[n]);
	return 0;	


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.