Coin Exchange Issues
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 9699 Accepted Submission (s): 5898
Problem description in a country only 1 points, 2 points, 3 cent coins, the exchange of money n into coins there are many kinds of laws. Please compile the procedure to calculate the total number of different methods.
Input has only one positive integer n,n less than 32768 per line.
Output corresponds to each input and the number of redemption methods.
Sample Input293412553
Sample Output71883113137761
Full backpack. Only the number of statistical programmes.
Dp[i] Represents the number of methods that comprise I. Then Dp[i] can be transferred by dp[i-1],dp[i-2],dp[i-3] ...
/************************************************author:guanjuncreated TIME:2016/12/6 11:36:45File Name: hdu1284.cpp*************************************************/#include<bits/stdc++.h>#defineull unsigned long Long#definell Long Long#defineMoD 90001#defineINF 0x3f3f3f3f#defineMAXN 10010#defineCLE (a) memset (A,0,sizeof (a))Constull inf = 1LL << A;Const Doubleeps=1e-5;using namespaceStd;priority_queue<int,vector<int>,greater<int> >PQ;structnode{intx, y;};structcmp{BOOL operator() (Node A,node b) {if(a.x==b.x)returnA.y>b.y; returnA.x>b.x; }};BOOLcmpintAintb) { returnA>b;}intdp[40000];intMain () {#ifndef Online_judge//freopen ("In.txt", "R", stdin); #endif //freopen ("OUT.txt", "w", stdout); intN; dp[0]=1; for(intI=1; i<=3; i++){ for(intj=i;j<=36000; j + +) Dp[j]+=dp[j-i]; } while(~SCANF ("%d",&N)) {printf ("%d\n", Dp[n]); } return 0;}
HDU 1284 Coin Exchange issues