302428: CF468A. 24 Game
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
24 Game
题意翻译
你有一个整数序列,包括 $n$ 个整数 $1\sim n$。你每次可以从其中拿出两个数 $a,b$,将这两个数从序列中删除,并将 $a+b$、$a-b$ 或 $a\times b$ 放入这个序列。 经过 $n-1$ 次操作后,序列中只会剩下一个数,若这个数可能为 $24$,输出 `YES` 与构造方案,否则,输出 `NO`。题目描述
Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of $ n $ integers: $ 1,2,...,n $ . In a single step, you can pick two of them, let's denote them $ a $ and $ b $ , erase them from the sequence, and append to the sequence either $ a+b $ , or $ a-b $ , or $ a×b $ . After $ n-1 $ steps there is only one number left. Can you make this number equal to $ 24 $ ?输入输出格式
输入格式
The first line contains a single integer $ n $ $ (1<=n<=10^{5}) $ .
输出格式
If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain $ 24 $ as the result number, in the following $ n-1 $ lines print the required operations an operation per line. Each operation should be in form: " $ a $ $ op $ $ b $ = $ c $ ". Where $ a $ and $ b $ are the numbers you've picked at this operation; $ op $ is either "+", or "-", or "\*"; $ c $ is the result of corresponding operation. Note, that the absolute value of $ c $ mustn't be greater than $ 10^{18} $ . The result of the last operation must be equal to $ 24 $ . Separate operator sign and equality sign from numbers with spaces. If there are multiple valid answers, you may print any of them.
输入输出样例
输入样例 #1
1
输出样例 #1
NO
输入样例 #2
8
输出样例 #2
YES
8 * 7 = 56
6 * 5 = 30
3 - 4 = -1
1 - 2 = -1
30 - -1 = 31
56 - 31 = 25
25 + -1 = 24