Autumn Cleaning (16 MiB ML!)
Time limit2sMemory limit16 MB
Count the k-element subsets of n item prices whose sum is divisible by r, modulo 10^6+3.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Combinatorics, Math, Implementation
- Solved
- No attempts yet
Problem
Autumn is coming, and Sophie wants to prepare for it by emptying her grandparents' basement. She wants to sell unused items, so she put a price tag on each of them (non-negotiable!) and posted the offer online. Some items may have the same price. A junk dealer contacted her quickly, and he wants to buy exactly items, no matter which ones (junk is junk). Unfortunately, he visited the ATM only a moment ago, so he has only a lot of -zloty bills ('zloty' is the Polish currency). In how many different ways can they make a trade?
Input
The first line of the input contains three positive integers and (, , ), denoting the number of items Sophie wants to sell, the number of items the junk dealer wants to buy, and the face value of the bills he has. The second and last line of the input contains positive integers (). These are the prices of the items Sophie wants to sell.
Output
Print a single positive integer: the remainder modulo of the number of sets of items whose total price is divisible by .
Hint
The junk dealer can buy the first, second and fifth items, with a total price of , or the first, third and fourth items, paying .