Description
After watching the performances, I quickly understood the secrets behind the magic. Then I came up with a similar magic. He asked his father to extract n cards from the 10000 cards, and then he would say the number of M cards at random, you can quickly determine whether the number is the sum of one or two of the N cards.
Of course, as the saying goes, if you have a father, you must have his son. Quick Bi is also an outstanding software engineer.
-
Input
-
An integer in the first row indicates the number of groups (multiple groups of data). For each group of data, the first row has two integers n (1 ≤ n ≤ 10000 ), M (1 ≤ m ≤ 100 ). The second row is the set of n different integers. The third row has m Integers to be verified.
-
Output
-
Output a line for each integer to be verified. If the set S contains two integers and the sum of the Integers to be verified, output "yes"; otherwise, output "no ".
-
Sample Input
-
110 53 1 8 4 7 9 5 10 2 627 7 26 10 11
-
Sample output
-
Noyesnoyesyes
Create an index with an array, and the number is 1 in the array. In this way, the subscript is used to determine whether the index is composed of two numbers, determine whether the array content is 1
# include
main () {int number, Te; int I, J, K, M; int number1, number2; int A [10000]; int result [100000]; int B; int flag; scanf ("% d", & number); For (TE = 1; te <= number; Te ++) {for (k = 0; k <100000; k ++) result [k] = 0; scanf ("% d", & number1, & number2); for (I = 1; I <= number1; I ++) {scanf ("% d", & A [I]); Result [A [I] = 1 ;}for (I = 1; I <= number2; I ++) {flag = 0; scanf ("% d", & B); For (j = 1; j <= number1/2; j ++) {If (result [B-A [J] = 1) Flag = 1; elsecontinue;} If (flag = 1) printf ("Yes \ n"); else printf ("NO \ n") ;}}