Point game time limit: theMs | Memory Limit:65535KB Difficulty:5
-
-
Describe
-
There is a game which are called point game.
In this game, you'll be given some numbers. Your task is to find a expression which the given numbers and the value of the expression should be 24. The expression mustn ' t has any other operator except Plus,minus,multiply,divide and the brackets.
e.g. If the numbers given is "3 3 8 8", you can Give "8/(3-8/3)" as an answer. All the numbers should is used and the bracktes can be nested.
Your task in this problem are only to judge whether the given numbers can being used to find a expression whose value is the G Iven number.
-
-
Input
-
-
The input has multicases and each case contains one line
The first line of the input was an non-negative integer C (c<=100), which indicates the number of the cases.
Each line have some integers,the first integer M (0<=m<=5) is the total number of the given numbers to consist the EXP ression,the second integers N (0<=n<=100) is the number which the value of the expression should be.
Then,the followed M integer is the given numbers. All the given numbers are non-negative and less than 100
-
-
Output
-
For each
-
test-cases,output ' Yes ' if there is a expression which fit all the demands,otherwise output "No" instead.
-
-
Sample input
-
-
24 24 3 3 8 83 24 8 3 3
-
-
Sample output
-
-
YesNo
-
-
Source
-
-
Classic Adaptations
-
Uploaded by
Zhang Yunzun
The problem is not difficult, there are only four possible, one-way search on the line!
The code is as follows:
Deep Search Nyoj point game