Output: Standard Output
Time Limit: 1 Second
Given a list of N numbers you will be allowed to choose any M
of them. So you can choose in NCM ways. You will have
to determine how many of these chosen groups have a sum, which is divisible by D.
The input file contains
maximum ten sets of inputs. The description of each set is given below.
The first line of each set
contains two integers N (0<N<=200) and Q (0<Q<=10). Here
N indicates how many numbers are there and Q is the total no of
query. Each of the next N lines contains one 32 bit signed
integer. Our queries will have to be answered based on these N numbers.
Next Q lines contain Q queries. Each query contains two integers D
(0<D<=20) and M (0<M<=10) whose meanings are explained
in the first paragraph.
Input is terminated by a
case whose N=0 and Q=0. This case should not be processed.
For each set of input, print the set number. Then for each query in the set print the query number followed by the number of desired groups. See sample output to know the exact output format.
10 2 1 2 3 4 5 6 7 8 9 10 5 1 5 2 5 1 2 3 4 5 6 6 2 0 0 |
SET 1: QUERY 1: 2 QUERY 2: 9 SET 2: QUERY 1: 1 |
Problemsetter:
Shahriar Manzoor, Member of Elite Problemsetters' Panel