|
||||||||||
BalanceTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 242 Accepted Submission(s): 4 Problem Description You are given a set of weight values and asked to measure something with a certain weight. Weight x is measurable with a set y of weight values if and only if you can do the following: Place one weight with value x on either the left or right side of the scale. Then place some combination of weights on the scale with values from the set y so that the left and right sides have the same total value. You may use each value in y zero or more times to achieve this. In order to reach the target, you choose a kind of weight randomly and try to measure with it. If you find it impossible, you choose an additional kind and try again until you can measure with the set of weights you have chosen. Now, please tell me the expect kinds of weight you have to choose. Input For each case, the first line is two integers n and m (1<=n<=15), which n represents the number of weights you have and m is the weight you have to measure. Followed by n positive integers ai (1<=i<=n), indicating the mass of each kind of weight. 0 < m,ai < 2^31. Output For each case, output -1 if you can't measure with all kinds of weight you have or the expect number of kinds you have to choose which rounded to 3 decimal places. Sample Input
Sample Output
| ||||||||||
|