#c221102. 硬币购物
硬币购物
Coin Shopping
Problem Source
HAOI2008
Problem Description
There are kinds of coins, with face values respectively.
A person goes shopping times. For each purchase, he brings coins of the -th kind and wants to buy goods worth . For each purchase, how many ways are there to pay?
Input Format
The first line contains five integers, representing .
The following lines each contain five integers describing one purchase, representing .
For of the data, and .
Output Format
For each purchase, output one line containing an integer: the answer.
Sample Input
1 2 5 10 2
3 2 3 1 10
1000 2 2 2 900
Sample Output
4
27