题目描述

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.

Code Forces 543A Writing Code的更多相关文章

  1. CodeForces 543A - Writing Code DP 完全背包

    有n个程序,这n个程序运作产生m行代码,但是每个程序产生的BUG总和不能超过b, 给出每个程序产生的代码,每行会产生ai个BUG,问在总BUG不超过b的情况下, 我们有几种选择方法思路:看懂了题意之后 ...

  2. Codeforces 543A Writing Code

    http://codeforces.com/problemset/problem/543/A 题目大意:n个人,一共要写m行程序,每个程序员每行出现的bug数为ai,要求整个程序出现的bug数不超过b ...

  3. 543A - Writing Code(二维动态规划)

    题意:现在要写m行代码,总共有n个文件,现在给出第i个文件每行会出现v[i]个bug,问你在bug少于b的条件下有多少种安排 分析:定义dp[i][j][k],i个文件,用了j行代码,有k个bug 状 ...

  4. Codeforces Round #302 (Div. 2).C. Writing Code (dp)

    C. Writing Code time limit per test 3 seconds memory limit per test 256 megabytes input standard inp ...

  5. 完全背包 Codeforces Round #302 (Div. 2) C Writing Code

    题目传送门 /* 题意:n个程序员,每个人每行写a[i]个bug,现在写m行,最多出现b个bug,问可能的方案有几个 完全背包:dp[i][j][k] 表示i个人,j行,k个bug dp[0][0][ ...

  6. [CF543A]/[CF544C]Writing Code

    [CF543A]/[CF544C]Writing Code 题目大意: 有\(n\)种物品,每种物品分别要\(c_i\)的代价,每个物品有\(1\)的体积,每个物品可以选多个,代价不能超过\(b\), ...

  7. (完全背包)Writing Code -- Codeforce 544C

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=99951#problem/C  (zznu14) Writing Code  Writin ...

  8. 思维题--code forces round# 551 div.2

    思维题--code forces round# 551 div.2 题目 D. Serval and Rooted Tree time limit per test 2 seconds memory ...

  9. Codeforces Round #302 (Div. 2) C. Writing Code 简单dp

    C. Writing Code Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/544/prob ...

随机推荐

  1. 51Nod 1684 子集价值 (平方和去括号技巧)

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1684 题意: 新建一个位运算,求所有子集通过这个位运算后的答案的平方和是 ...

  2. 在 Linux 中安装 VMware Tools

    由于较新的Linux版本中都包含了vm的部分组件,导致直接安装VMware Tools失败.所以这里写了篇新的. 软件版本:VMware 12 Linux版本:Ubuntu Desktop 16.04 ...

  3. CString 与其它数据类型转换问题

    CString 头文件#include <afx.h> string 头文件#include <string.h> CString 转char * CString cstr; ...

  4. CSS position:absolute浅析

    一.绝对定位的特征 绝对定位有着与浮动一样的特性,即包裹性和破坏性. 就破坏性而言,浮动仅仅破坏了元素的高度,保留了元素的宽度:而绝对定位的元素高度和宽度都没有了. 请看下面代码: <!DOCT ...

  5. 洛谷 P3749: LOJ 2146: [SHOI2017]寿司餐厅

    题目传送门:LOJ #2146. 题意简述: 有 \(n\) 种寿司,第 \(i\) 种寿司的类型为 \(a_i\). 如果你吃了第 \(i\) 种到第 \(j\) 种寿司,你会得到 \(d_{i,j ...

  6. 【逆向工具】IDA Python安装与使用

    1.IDA Pyhon介绍 IDA Python是IDA6.8后自带插件,可以使用Python做很多的辅助操作,非常方便的感觉. 2.IDA Python安装 从github上IDAPython项目获 ...

  7. USB的挂起和唤醒(Suspend and Resume)【转】

    转自:http://m.blog.csdn.net/blog/luckywang1103/25244091 USB协议的第9章讲到USB可见设备状态[Universal Serial Bus Spec ...

  8. MySQL binlog导入失败

    一个同事问我,说他用innobackupex恢复数据后用mysqlbinlog导入增量数据时,发现数据没有导入进去并且也没有报错. mysqlbinlog /u01/mysql_py/database ...

  9. OracleDBConsoleorcl 启动不了 服务特定错误2【解决办法】

    问题描述: 我的oracle不知道为什么OracleDBConsoleorcl 启动不了 出现“服务特定错误2”现在我也不知道原因 估计是因为我电脑的IP经常变动,有时在公司用,有时在家里用! 我的o ...

  10. Error updating database. Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String异常处理

    问题原因:Mybatis中对于时间参数进行比较时的一个BUG. 如果拿传入的时间类型参数与空字符串‘‘进行对比判断则会引发异常.,所以应该去掉该判断, 只保留非空判断就正常了 <if test= ...