Submit | All submissions | Best solutions | Back to list |
DCEPC14F - The Toy Store |
One day Amit had an idea to open up a toy store. Though he realised that he must do something to attract customers to his store otherwise his store would not be successful. So he comes up with a plan to give each customer a free Lego (blocks) set. Hearing about this, you go to the store to get your free sample.
You are provided with a set of Legos. The set given to you consists of N different kinds of Lego. The set has an infinite number of pieces of each kind of Lego. Each kind of Lego has some fixed height. Note that 2 different kinds of Lego may have the same height.
Now you want to check the actual price of your Lego set. The price of the set is equal to the number of distinct Beautiful Buildings that can be built using the set.
A Beautiful Building is a stack of Lego pieces such that it is made of exactly K Lego pieces (not necessarily of different kind) and its height is equal to X modulo M for given values of X, M and K (these values are printed on the box).
2 Buildings are distinct if there exists a height H at which the block used in both buildings is not the same.
You want to find out the price of the free sample provided to you.
Input
The input starts with an integer T, indicating the number of test cases. Then T test cases follow. Each test cases consists of 3 lines. The first line contains an integer N, indicating the number of different kinds of Lego in the set. The second line contains N space separated integers, the ith of which represents the height of pieces of ith kind. The third line contains 3 space separated integers representing the values of M, K and X respectively.
Output
For each test case print a line containing the price of the set modulo 1000000007.
CONSTRAINTS
T<=100
1<=N<=100000
1<=M<=100
1<=K<=1000000000
0<=X
Example
Input:
2
3
1 2 3
3 1 0
3
1 2 3
3 2 0 Output: 1
3
Added by: | dce coders |
Date: | 2015-04-26 |
Time limit: | 0.5s-1.5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | C CSHARP C++ 4.3.2 CPP CPP14 C99 GOSU JAVA PAS-GPC PAS-FPC PYTHON PYPY PYTHON3 PY_NBC |
hide comments
2015-06-27 06:29:58 Samir Ahmed
For both the cases we have X=0 so X mod M should be 0(the target height). How come we have the results 1 and 3? Last edit: 2015-06-27 06:30:53 |
|
2015-05-03 19:45:57 dce coders
@_R0b_ You are right. Changes have been made to constraints. |
|
2015-05-02 22:27:52 _R0b_
@admin / fix this - look at the CONSTRAINTS and look at sample Example you are saying 1<=M<=100 1<=X<=M means X >= 1 and in sample Example you write X = 0 , How ? |