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 ...
随机推荐
- scrapy 简单防封
设置爬取间隔 setting.py from random import random DOWNLOAD_DELAY = random()* ps:此次的爬取间隔,在读取seeting文件确定,并非每 ...
- sh脚本学习之:变量
变量的创建 环境配置 /etc/profile =>~/.bash_profile(~/.bash_login,~/.profile) => ~/.bashrc sh声明 name=&qu ...
- html5 canvas 垂直渐变描边
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- mysql先排序在分组
– 表的结构 `test`– CREATE TABLE IF NOT EXISTS `test` (`id` int(11) NOT NULL AUTO_INCREMENT,`name` varcha ...
- 第10月第28天 touchesBegan hittest
1. -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [[self nextResponder] touchesBe ...
- 转载一篇介绍CUDA
鉴于自己的毕设需要使用GPU CUDA这项技术,想找一本入门的教材,选择了Jason Sanders等所著的书<CUDA By Example an Introduction to Genera ...
- MySQL-存储过程procedure
存储过程:是一个SQL语句集合,当主动去调用存储过程时,其中内部的SQL语句会按照逻辑执行. 1.创建存储过程: -- 创建存储过程 delimiter // create procedure p1( ...
- linux如何查看端口被哪个进程占用?
参考:https://jingyan.baidu.com/article/546ae1853947b71149f28cb7.html 1.lsof -i:端口号 2.netstat -tunlp|gr ...
- spfa学习笔记
序 spfa它死了 --by 大佬 但是本蒟蒻还是一如既往的使用spfa... 因为太弱了,其他什么都不会.于是就疯狂开O2跪倒在spfa上. 例题--汽车加油行驶问题 loj跳转链接 luogu跳转 ...
- Intellij IDEA15: 带着参数 运行
package main.scala /** * Created by silentwolf on 2016/5/24. */ object FileIO { def main(args: Array ...