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.
Code Forces 543A Writing Code的更多相关文章
- CodeForces 543A - Writing Code DP 完全背包
有n个程序,这n个程序运作产生m行代码,但是每个程序产生的BUG总和不能超过b, 给出每个程序产生的代码,每行会产生ai个BUG,问在总BUG不超过b的情况下, 我们有几种选择方法思路:看懂了题意之后 ...
- Codeforces 543A Writing Code
http://codeforces.com/problemset/problem/543/A 题目大意:n个人,一共要写m行程序,每个程序员每行出现的bug数为ai,要求整个程序出现的bug数不超过b ...
- 543A - Writing Code(二维动态规划)
题意:现在要写m行代码,总共有n个文件,现在给出第i个文件每行会出现v[i]个bug,问你在bug少于b的条件下有多少种安排 分析:定义dp[i][j][k],i个文件,用了j行代码,有k个bug 状 ...
- 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 ...
- 完全背包 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][ ...
- [CF543A]/[CF544C]Writing Code
[CF543A]/[CF544C]Writing Code 题目大意: 有\(n\)种物品,每种物品分别要\(c_i\)的代价,每个物品有\(1\)的体积,每个物品可以选多个,代价不能超过\(b\), ...
- (完全背包)Writing Code -- Codeforce 544C
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=99951#problem/C (zznu14) Writing Code Writin ...
- 思维题--code forces round# 551 div.2
思维题--code forces round# 551 div.2 题目 D. Serval and Rooted Tree time limit per test 2 seconds memory ...
- 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 ...
随机推荐
- JMS学习(三)ActiveMQ Message Persistence
1,JMS规范支持两种类型的消息传递:persistent and non-persistent.ActiveMQ在支持这两种类型的传递方式时,还支持消息的恢复.中间状态的消息(message are ...
- 安装mongodb以及设置为windows服务 详细步骤
我的win7 32的,注意版本要正确! 一.下载mongodb压缩包:mongodb-win32-i386-2.6.9.zip() 二.在D盘新建文件夹mongodb,将压缩我的解压文件放进去(有一个 ...
- 20155203 2016-2017-4 《Java程序设计》第6周学习总结
20155203 2016-2017-4 <Java程序设计>第6周学习总结 教材学习内容总结 重载和覆盖:重载是将函数的名称和方法不变(名称可以有一些变动),只改变参数列表,相当于和原来 ...
- MongoDB 之 $关键字 及 $修改器 $set $inc $push $pull $pop MongoDB - 4
我们在之前的 MongoDB 之 手把手教你增删改查 MongoDB - 2 中提到过 $set 这个系统关键字,用来修改值的对吧 但是MongoDB中类似这样的关键字有很多, $lt $gt $lt ...
- Maven私服安装及配置——(十二)
0.私服实际是B/S架构的,需要通过浏览器访问.访问地址在 nexus-2.12.0-01\conf\nexus.properties中查看.
- 初始ASP.NET数据控件【续 DataList】
DataList控件 DataList控件也是一个常用的数据绑定控件,相对于GridView控件虽然没它那么强大的功能,但是灵活性却很强势.因为其本身就是一个富有弹性的控件.DataList控件可以 ...
- com.alibaba.fastjson.JSONException: autoType is not support.
解决办法:https://github.com/alibaba/fastjson/wiki/enable_autotype 文摘如下: 一.添加autotype白名单 添加白名单有三种方式,三选一,如 ...
- java虚拟机规范(se8)——java虚拟机结构(二)
2.5 运行时数据区域 java虚拟机定义了多个用于程序执行期间的运行时数据区域.这些数据区域中一些随着java虚拟机的启动而创建,随着虚拟机的退出而销毁.其他的数据区域时和线程相关的.线程相关数据区 ...
- Eureka的自我保护模式
一 Eureka的自我保护模式 进入自我保护模式最直观的体现就是Eureka Server首页的警告,如下图: 默认情况下,如果Eureka Server在一定时间内没有接收到某个微服务实例的心跳,E ...
- tensorflow variable的保存和修改(加载一部分variable到新的model中)
link: https://www.tensorflow.org/guide/saved_model 中文博客:https://blog.csdn.net/Searching_Bird/article ...