A9951 | Writing Code
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Programmers working on a large project have just received a task to write exactly $m$ lines of code. There are $n$ programmers working on a project, the $i$ -th of them makes exactly $a_{i}$ bugs in every line of code that he writes.
Let's call a sequence of non-negative integers $v_{1},v_{2},...,v_{n}$ a plan, if $v_{1}+v_{2}+...+v_{n}=m$ . The programmers follow the plan like that: in the beginning the first programmer writes the first $v_{1}$ lines of the given task, then the second programmer writes $v_{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 $b$ 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 $mod$ .
Let's call a sequence of non-negative integers $v_{1},v_{2},...,v_{n}$ a plan, if $v_{1}+v_{2}+...+v_{n}=m$ . The programmers follow the plan like that: in the beginning the first programmer writes the first $v_{1}$ lines of the given task, then the second programmer writes $v_{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 $b$ 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 $mod$ .
输入格式
The first line contains four integers $n$ , $m$ , $b$ , $mod$ ( $1<=n,m<=500$ , $0<=b<=500$ ; $1<=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 $n$ space-separated integers $a_{1},a_{2},...,a_{n}$ ( $0<=a_{i}<=500$ ) — the number of bugs per line for each programmer.
The next line contains $n$ space-separated integers $a_{1},a_{2},...,a_{n}$ ( $0<=a_{i}<=500$ ) — the number of bugs per line for each programmer.
输出格式
Print a single integer — the answer to the problem modulo $mod$ .
输入输出样例
输入 #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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted