1708: [Usaco2007 Oct]money cow's coin

Source: Internet
Author: User

1708: [Usaco2007 Oct]money cow's coin time limit:5 Sec Memory limit:64 MB
submit:544 solved:352
[Submit] [Status] Description

After the creation of their own regime, the cows decided to promote the new currency system. Driven by a strong rebellious mentality, they were prepared to use strange denominations. In the traditional monetary system, coins are usually 1,5,10,20 or 25, 50, and 100 units of currency, sometimes for more convenient trading, will issue a denomination of 2 units of coins. Cows want to know how many different ways a given monetary system would be if it needed to make a certain amount of money. For example, you have an infinite number of face values for {1,2,5,10, ...} Coins, and intend to make up 18 units of currency, then you have a number of ways to achieve your goal: 18*1,9*2,8*2+2*1,3*5+2+1, as well as other unlisted programs. Please write a program to help the cows calculate, if you want to use a V (1 <= v <= 25) Denomination of the coin, the total value of N (1 <= N <= 10,000) of a pile of money, there are altogether how many different methods. The answer is guaranteed to be no more than the ' long ' in C + +, ' Int64 ' in Pascal, or the ' long ' range in Java.

Input

* Line 1th: 2 integers separated by a space: V and N

* 2nd. V+1 line: 1 integers per line, representing 1 denominations of coins

Output

* Line 1th: Output 1 positive integers, representing the total number of different methods for the sum of the n units of the coins in this v denomination.

Sample Input3 10
1
2
5
Sample OutputTenHINT Source

Gold

Problem: True water ... is the infinite knapsack question, asks the kind number, the basic way does not change (hansbug: The tease ratio I still is the inner circulation b[i] writes A[i], then Wawawaa ... TT phile: I'm drunk, too.

1 var2 I,j,k,m,n:longint;l:int64;3A:Array[0..20000] ofInt64;4B:Array[0.. -] ofLongint;5 begin6 readln (m,n);7       fori:=1  toM Doreadln (B[i]);8Fillchar (A,sizeof (a),0);9a[0]:=1;Ten       fori:=1  toM Do One           forJ:=b[i] toN Do Aa[j]:=a[j]+a[j-B[i]]; - Writeln (A[n]); - End.

1708: [Usaco2007 Oct]money cow's coin

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.