1265 card sum

Source: Internet
Author: User
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") ;}}
   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.