eolymp
bolt
Try our new interface for solving problems
Məsələlər

Cracking the Safe

Cracking the Safe

Secret agent Roger is trying to crack a safe containing evil Syrian chemical weapons. In order to crack the safe, Roger needs to insert a key into the safe. The key consists of four digits. Roger has received a list of possible keys from his informants that he needs to try out. Trying out the whole list will take too long, so Roger needs to find a way to reduce the list. A valid key satisfies a certain condition, which we call the \textbf{24} condition. Four digits that satisfy the \textbf{24} condition can be manipulated using addition, subtraction, multiplication, division and parentheses, in such a way, that the end result equals \textbf{24}. For example, the key \textbf{(4, 7, 8, 8)} satisfies the \textbf{24} condition, because \textbf{(7-8/8)*4} = \textbf{24}. The key \textbf{(1, 1, 2, 4)} does not satisfy the \textbf{24} condition, nor does \textbf{(1, 1, 1, 1)}. These keys cannot possibly be the valid key and do not need to be tried. Write a program that takes the list of possible keys and outputs for each key whether it satisfies the \textbf{24} condition or not. \InputFile On the first line one positive number: the number of test cases, at most \textbf{100}. After that per test case: one line with four space-separated integers \textbf{a}, \textbf{b}, \textbf{c}, \textbf{d }(\textbf{1 }≤ \textbf{a}, \textbf{b}, \textbf{c}, \textbf{d }≤ \textbf{9}): a possible key. \OutputFile Per test case: one line with either "\textbf{YES}" or "\textbf{NO}", indicating whether the key satisfies the \textbf{24 }condition or not.
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
4
4 7 8 8
1 1 2 4
1 1 1 1
1 3 4 6
Çıxış verilənləri #1
YES
NO
NO
YES
Mənbə 2013 Benelux Algorithm Programming Contest (BAPC), Preliminaries, September 28, Problem C