CF543A.Writing Code

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

Let's call a sequence of non-negative integers v1,v2,...,vnv_{1},v_{2},...,v_{n} a plan, if v1+v2+...+vn=mv_{1}+v_{2}+...+v_{n}=m . The programmers follow the plan like that: in the beginning the first programmer writes the first v1v_{1} lines of the given task, then the second programmer writes v2v_{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 bb 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 modmod .

输入格式

The first line contains four integers nn , mm , bb , modmod ( 1<=n,m<=5001<=n,m<=500 , 0<=b<=5000<=b<=500 ; 1<=mod<=109+71<=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 nn space-separated integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 0<=ai<=5000<=a_{i}<=500 ) — the number of bugs per line for each programmer.

输出格式

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

输入输出样例

  • 输入#1

    3 3 3 100
    1 1 1
    

    输出#1

    10
    
  • 输入#2

    3 6 5 1000000007
    1 2 3
    

    输出#2

    0
    
  • 输入#3

    3 5 6 11
    1 2 1
    

    输出#3

    0
    
首页