# P1077 and p1077

Source: Internet
Author: User

P1077 and p1077
Description

James's flower shop is newly opened. To attract customers, he wants to put a row of flowers at the door of the flower shop, a total of m pots. By investigating the customer's preferences, James listed the n flowers that the customer liked most, ranging from 1 to n. In order to display more flowers at the door, it is stipulated that the I-type flowers should not exceed the ai basin. When the flowers are placed together, the same flowers should be arranged in the order of numbers from small to large.

The number of different pendulum schemes for trial programming and computing.

Input/Output Format Input Format:

The first line contains two positive integers n and m, separated by a space.

The second row has n integers separated by a space, indicating a1, a2 ,...... An.

Output Format:

The output contains only one row and an integer, indicating the number of solutions. Note: because the number of solutions may be large, please output the result of Modulo of the number of solutions to 1000007.

Input and Output sample Input example #1:
`2 43 2`
Output sample #1:
`2`
Description

[Data Scope]

For 20% of data, there are 0 <n ≤ 8, 0 <m ≤ 8, 0 ≤ ai ≤ 8;

For 50% of data, there are 0 <n ≤ 20, 0 <m ≤ 20, 0 ≤ ai ≤ 20;

For 100% of data, there are 0 <n ≤ 100, 0 <m ≤, 0 ≤ ai ≤.

Topic 3 of NOIP 2012 popularization Group

Use dp [I] [j] to represent the first I flowers and put the number of j flowers

Then you can enumerate the number of flowers that can be placed in k.

Transfer equation:

Dp [I] [j] + = (dp [I-1] [k]) % 1000007

`1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 # include <cmath> 5 using namespace std; 6 const int MAXN = 101; 7 int read (int & n) 8 {9 char p = '+'; int x = 0; 10 while (p <'0' | p> '9 ') 11 p = getchar (); 12 while (p> = '0' & p <= '9') 13 x = x * 10 + p-48, p = getchar (); 14 n = x; 15} 16 int n, m; 17 int dp [MAXN] [MAXN]; 18 int num [MAXN]; 19 int main () 20 {21 read (n); read (m); 22 for (int I = 1; I <= n; I ++) 23 read (num [I]), dp [I] [0] = 1; 24 dp [0] [0] = 1; 25 for (int I = 1; I <= n; I ++) // each flower 26 {27 for (int j = 1; j <= m; j ++) 28 {29 for (int k = j; k> = j-num [I] & k> = 0; k --) 30 {31 dp [I] [j] + = (dp [I-1] [k]) % 1000007; 32} 33} 34} 35 cout <dp [n] [m] % 1000007; 36 return 0; 37}`

Related Keywords:
Related Article

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.