F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Jam's balance

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 4663    Accepted Submission(s): 1700


Problem Description
Jim has a balance and N weights. $(1 \leq N \leq 20)$
The balance can only tell whether things on different side are the same weight.
Weights can be put on left side or right side arbitrarily.
Please tell whether the balance can measure an object of weight M.
 

Input
The first line is a integer $T(1 \leq T \leq 5)$, means T test cases.
For each test case :
The first line is $N$, means the number of weights.
The second line are $N$ number, i'th number $w_i (1 \leq w_i \leq 100)$ means the i'th weight's weight is $w_i$.
The third line is a number $M$. $M$ is the weight of the object being measured.
 

Output
You should output the "YES"or"NO".
 

Sample Input
1 2 1 4 3 2 4 5
 

Sample Output
NO YES YES
 

Hint

For the Case 1:Put the 4 weight alone
For the Case 2:Put the 4 weight and 1 weight on both side
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 07:39:23, Gzip enabled