lightoj1127

maksyuki 发表于 oj 分类,标签:
0

1127 - Funny Knapsack

InputGiven n integers and a knapsack of weight W, you have to count the number of combinations for which you can add the items in the knapsack without overflowing the weight.

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case contains two integers n (1 ≤ n ≤ 30) and W (1 ≤ W ≤ 2 * 109) and the next line will contain n integers separated by spaces. The integers will be non negative and less than 109.

Output

For each set of input, print the case number and the number of possible combinations.

Sample Input

Output for Sample Input

31 111 12

3 10

1 2 4

Case 1: 2Case 2: 1Case 3: 8

 

题目类型:折半枚举

算法分析:由于物品的个数比较少,所以将物品大致分为两堆,然后分别枚举组合的情况,最后再查找小于w的组合个数