Problem description Xiao Ming's flower Shop opened, in order to attract customers, he wanted to put a row of flowers at the door of the florist, a total of M basin. By investigating customers ' preferences, Xiao Ming lists the customers ' favorite n flowers, numbered from 1 to N. In order to show more flowers at the door, I can not grow more flowers than the AI basin, put flowers together with the same flowers, and different types of flowers need to be labeled from small to large order.
Test programming calculation, there are a total of how many different flower schemes. Input format the first line contains two positive integers n and M, with one space separating the middle.
The second line has n integers, separated by a space between each two integers, which in turn represent A1, A2 、...... an. Output format output has only one row, an integer, indicating how many scenarios.Note: Because the number of scenarios may be large, output the number of scenarios to1000007The result of the modulo. Sample Input 2 4
3 2 Sample Output 2 input and output sample shows that there are 2 kinds of flowers in the scheme, respectively (1,1,1,2), (1,1,2,2). The parentheses of 1 and 2 denote two flowers, such as the first three positions of the first flower, the fourth position of the second flower. Data size and conventions for 20% data, there are 0<n≤8,0<m≤8,0≤ai≤8;
For 50% data, there are 0<n≤20,0<m≤20,0≤ai≤20;
For 100% data, there is 0<n≤100,0<m≤100,0≤ai≤100.
1 ImportJava.util.Scanner;2 3 Public classMain {4 5 /**6 * @paramPendulum Flower7 * @return 8 */9 Static inta[];Ten Static intf[]; One Static intsum = 0; A Public Static voidMain (string[] args) { -Scanner sc =NewScanner (system.in); - intn =sc.nextint (); the intm =sc.nextint (); - -A =New int[102]; -f =New int[102]; + for(inti = 1; I <= N; ++i) { -A[i] =Sc.nextint (); + } AF[0] = 1; at for(inti = 1, j, K; I <= N; sum = 0, + +i) - { - for(j = m, sum = 0; j > a[i]; f[j] = sum, sum = 0,--j) - for(k = j-a[i]; k <= J; sum%= 1000007, + +k) -Sum + =F[k]; - for(j = a[i], sum = 0; j >-1; f[j] = sum, sum = 0,---j) in for(k = 0; k <= j; sum%= 1000007, + +k) -Sum + =F[k]; to } + //System.out.print (sum+ ' \ n '); - System.out.println (f[m]); the } *}
Blue Bridge Cup Java algorithm to improve flower swing