codeforces-scrape

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

1463A.md (2206B)


      1 Source: https://codeforces.com/problemset/problem/1463/A
      2 
      3 A. Dungeon
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 You are playing a new computer game in which you have to fight monsters. In a dungeon you are trying to clear, you met three monsters; the first of them has $a$ health points, the second has $b$ health points, and the third has $c$.
     22 
     23 To kill the monsters, you can use a cannon that, when fired, deals $1$ damage to the selected monster. Every $7$-th (i. e. shots with numbers $7$, $14$, $21$ etc.) cannon shot is enhanced and deals $1$ damage to all monsters, not just one of them. If some monster's current amount of health points is $0$, it can't be targeted by a regular shot and does not receive damage from an enhanced shot.
     24 
     25 You want to pass the dungeon beautifully, i. e., kill all the monsters with the same enhanced shot (i. e. after some enhanced shot, the health points of each of the monsters should become equal to $0$ for the first time). Each shot must hit a monster, i. e. each shot deals damage to at least one monster.
     26 
     27 Input
     28 
     29 The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases.
     30 
     31 Each test case consists of a single line that contains three integers $a$, $b$ and $c$ ($1 \le a, b, c \le 10^8$) — the number of health points each monster has.
     32 
     33 Output
     34 
     35 For each test case, print YES if you can kill all the monsters with the same enhanced shot. Otherwise, print NO. You may print each letter in any case (for example, YES, Yes, yes, yEs will all be recognized as positive answer).
     36 
     37 Example
     38 
     39 Input
     40 
     41 ```
     42 3
     43 3 2 4
     44 1 1 1
     45 10 1 7
     46 ```
     47 
     48 Output
     49 
     50 ```
     51 YES
     52 NO
     53 NO
     54 ```
     55 
     56 Note
     57 
     58 In the first test case, you can do as follows: $1$-th shot to the first monster, $2$-th shot to the second monster, $3$-th shot to the third monster, $4$-th shot to the first monster, $5$-th shot to the third monster, $6$-th shot to the third monster, and $7$-th enhanced shot will kill all the monsters.
     59 
     60 In the second test case, you can't kill monsters with the same enhanced shot, because the total number of health points of monsters is $3$, and you will kill them in the first 3 shots.