问题4142--X

4142: X

[命题人 : ]
时间限制 : 1.000 sec  内存限制 : 128 MB

题目描述

    We have a toy of which the price is N dollars, and we have K kinds of
coins. Now I want you to tell me that if we know the the number of coins 
each, then how many ways can we pay for the toy.

输入

     There will be multiple data sets, process the program to the end of file. First line are two integers N and K(N <= 10^5,k <= 7), the second line we have k integers a[i] (1 <= a[i] <= 100). Then I will give you an integer M, which denotes there are questions, (M <= 10^5), for each question, I will give you  k integers (b[1],b[2] .... b[k],b[i] <= 10^5,denotes the number of coins each.

输出

    Output M lines, ith line contains the answer for the ith question tell 
    me the answer for each question. It is granteeded that the answer will  be fit into bit-signed 64bit integer.

样例输入 Copy

900 4
1 2 5 10
2
3 2 3 1
1000 2 2 2

样例输出 Copy

0
27

来源/分类