#QHD0000091. Lập kế hoạch viết mã (Writing Code)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Lập kế hoạch viết mã (Writing Code)
Writing Code
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A software project requires exactly lines of code. There are programmers. Every line written by programmer introduces exactly bugs.
A plan is a sequence of nonnegative integers where is the number of lines assigned to programmer . A plan is good if:
$$\sum_{i=1}^{n}v_i=m,\qquad \sum_{i=1}^{n}v_i a_i\le b.$$Two plans differ if at least one programmer receives a different number of lines. A programmer may be assigned zero lines or any positive number of lines, provided the total is exactly . Programmers with the same bug rate are still distinct people; swapping their assignments may yield distinct plans.
Count good plans modulo the supplied positive integer mod. The modulus need not be prime, and modular division is unnecessary. If mod=1, the result is zero.
Input
The first line contains four integers . The second line contains integers , the per-line bug counts.
Output
Print one integer: the number of good plans modulo mod.
Subtasks
-
Subtask 1 (20 points): , , , .
-
Subtask 2 (30 points): , , , .
-
Subtask 3 (50 points): , , , .
Examples
Example 1
Input
3 3 3 100
1 1 1
Output
10
Explanation: Each line causes one bug, so every plan with three lines has three bugs. The number of nonnegative solutions to is inom{5}{2}=10.
Example 2
Input
2 2 1 1000
0 1
Output
2
Explanation: The three two-line plans are . The last has two bugs and is invalid. Thus there are two good plans.