## NWERC05 A - Unequalled Consumption

View as PDF

Points: 25
Time limit: 1.0s
Memory limit: 1G

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

The Association of Candy Makers is preparing to launch a new product. Its idea is old with a novel twist: it simply sells boxes of candies. But since people are what they consume and everyone wants to be unique these days, the ACM wants every candy box to be unique, in the sense that no two boxes should contain the same composition of candy types.

The ACM is only able to make a small number of different types of candy, but while limited in imagination, it is virtually limitless in resources, so it is able to produce as many as it wants of each type of candy. Furthermore, the candy types have different weights (though some may weigh the same), and in order to simplify pricing matters, the ACM wants all candy boxes to have the same total weight.

With these restrictions, the ACM will only be able to make a limited number of boxes. For instance, if there are three types of candy, weighing and grams respectively, different boxes can be made with total weight grams (using either two of type 1, or two of type 2, or one of type 3, or one each of types 1 and 2). The ACM would like to be able to make at least one box for everyone in the cosmos. So, given queries in the form of the number of people in the cosmos, your job is to find the smallest possible total weight such that different boxes containing exactly grams of candies can be made.

#### Input Specification

The input consists of several data sets (at most ). Each data set consists of four lines. The first line contains an integer , the number of candy types. The next line contains integers , where is the weight (in grams) of the :th candy type. The third line contains an integer , the number of queries. The last line of a data set contains integers , where is the :th query. Input is terminated by an incomplete data set where , which should not be processed.

#### Output Specification

For the :th data set, write a line "Set ", followed by lines giving, for each query , the minimal possible positive weight (in grams) of a candy box. If there is no weight such that at least candy boxes can be made, print “no candy for you” for that query. You may assume that , if it exists, will be at most .

#### Sample Input

3
5 5 10
1
4
4
3 1 4 2
2
142 700
1
10
1
100
0

#### Sample Output

Set 1
10
Set 2
23
42
Set 3
no candy for you