#P4720. Writing Code

Writing Code

Writing Code

题面翻译

题目描述:

nn 个程序员,每个程序员都可以写任意行代码,总共要编写 mm 行代码,这 mm 行代码可以由多个程序员来编写。但是第 ii 个程序员在一行代码中会出现 aia_i 个 bug。现在希望知道有多少种方案能使得这 mm 行代码中的 bug 的数量不超过 bb 个。
两个方案不同当且仅当某个程序员编写的代码量(行数)不同。

输入格式:

输入第一行包含四个整数 n,m,b,modn,m,b,mod
接下来一行 nn 个整数 aia_i

输出格式:

输出一行一个整数,表示 mm 行代码 bug 数量不超过 bb 的方案数对 modmod 取模后的答案。

提示说明:

$1 \le n,m \le 500,0 \le b \le 500;1 \le mod \le 10^9+7;0 \le a_i \le 500$

Translated by @Mine_King

题目描述

Programmers working on a large project have just received a task to write exactly m m lines of code. There are n n programmers working on a project, the i i -th of them makes exactly ai a_{i} bugs in every line of code that he writes.

Let's call a sequence of non-negative integers v1,v2,...,vn v_{1},v_{2},...,v_{n} a plan, if v1+v2+...+vn=m v_{1}+v_{2}+...+v_{n}=m . The programmers follow the plan like that: in the beginning the first programmer writes the first v1 v_{1} lines of the given task, then the second programmer writes v2 v_{2} more lines of the given task, and so on. In the end, the last programmer writes the remaining lines of the code. Let's call a plan good, if all the written lines of the task contain at most b b bugs in total.

Your task is to determine how many distinct good plans are there. As the number of plans can be large, print the remainder of this number modulo given positive integer mod mod .

输入格式

The first line contains four integers n n , m m , b b , mod mod ( 1<=n,m<=500 1<=n,m<=500 , 0<=b<=500 0<=b<=500 ; 1<=mod<=109+7 1<=mod<=10^{9}+7 ) — the number of programmers, the number of lines of code in the task, the maximum total number of bugs respectively and the modulo you should use when printing the answer.

The next line contains n n space-separated integers a1,a2,...,an a_{1},a_{2},...,a_{n} ( 0<=ai<=500 0<=a_{i}<=500 ) — the number of bugs per line for each programmer.

输出格式

Print a single integer — the answer to the problem modulo mod mod .

样例 #1

样例输入 #1

3 3 3 100
1 1 1

样例输出 #1

10

样例 #2

样例输入 #2

3 6 5 1000000007
1 2 3

样例输出 #2

0

样例 #3

样例输入 #3

3 5 6 11
1 2 1

样例输出 #3

0