Code Forces 543A Writing Code

Code Forces 543A Writing Code

题目描述

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 a_{i}ai bugs in every line of code that he writes.

Let's call a sequence of non-negative integers v_{1},v_{2},...,v_{n}v1,v2,...,vn a plan, if v_{1}+v_{2}+...+v_{n}=mv1+v2+...+vn=m . The programmers follow the plan like that: in the beginning the first programmer writes the first v_{1}v1 lines of the given task, then the second programmer writes v_{2}v2 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<=10^{9}+71<=mod<=109+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 a_{1},a_{2},...,a_{n}a1,a2,...,an ( 0<=a_{i}<=5000<=ai<=500 ) — the number of bugs per line for each programmer.

 

输出格式:

 

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

 

Let us confirm that dp[i][j][k] means 1~i programmers finished j line of codes and they got k's bugs.

That is easy to know that dp[i][j][k]=dp[i-1][j-1][j-bug[i]]

Then we need a rounded array to pass the memory limited.

posted @ 2019-01-25 19:58 Dijkstra·Liu 阅读( ...) 评论( ...) 编辑 收藏
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值