# Va 674 coin change

Source: Internet
Author: User

Uva_674

You can use deep search to solve this problem. You can enumerate the quantity selected for each non-1 nominal value. The remaining nominal value must be set to 1. In order to make full use of the subproblem solution, we can retain all the subproblems in the computing process. When other results need to be calculated, directly return the record value.

`# Include <stdio. h># Include < String . H> # Define Maxd 8000 Int F [maxd] [ 5 ], A [] = { 50 , 25 , 10 , 5 , 1 }; Int N; Int DFS ( Int Cur, Int St){ Int I, A = 0 ; If (F [cur] [st]) Return F [cur] [st]; If (St = 4 )Return F [cur] [st] = 1 ; For (I = 0 ; A [st] * I <= cur; I ++)A + = DFS (cur-A [st] * I, ST + 1 ); Return F [cur] [st] =;} Int Main (){ Int I;Memset (F, 0 ,Sizeof (F )); For (I = 0 ; I < 5 ; I ++)F [ 0 ] [I] = 1 ; While (Scanf ( "  % D  " , & N) = 1 ){Printf ( " % D \ n  " , DFS (n, 0 ));} Return   0 ;}`

Related Keywords:

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.