codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

468A.md (1609B)


      1 Source: https://codeforces.com/problemset/problem/468/A
      2 
      3 A. 24 Game
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 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.
     22 
     23 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*.
     24 
     25 After *n* - 1 steps there is only one number left. Can you make this number equal to 24?
     26 
     27 Input
     28 
     29 The first line contains a single integer *n* (1 ≤ *n* ≤ 105).
     30 
     31 Output
     32 
     33 If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes).
     34 
     35 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 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces.
     36 
     37 If there are multiple valid answers, you may print any of them.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 1
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 NO
     51 ```
     52 
     53 Input
     54 
     55 ```
     56 8
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 YES  
     63 8 * 7 = 56  
     64 6 * 5 = 30  
     65 3 - 4 = -1  
     66 1 - 2 = -1  
     67 30 - -1 = 31  
     68 56 - 31 = 25  
     69 25 + -1 = 24
     70 ```