codeforces-scrape

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

1097B.md (2259B)


      1 Source: https://codeforces.com/problemset/problem/1097/B
      2 
      3 B. Petr and a Combination Lock
      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 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:
     22 
     23  ![](https://espresso.codeforces.com/f7117555982acf5711ed387490b8ba9fc00be3f4.png) 
     24 
     25 Petr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.
     26 
     27 This confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.
     28 
     29 Input
     30 
     31 The first line contains one integer $n$ ($1 \leq n \leq 15$) — the number of rotations.
     32 
     33 Each of the following $n$ lines contains one integer $a_i$ ($1 \leq a_i \leq 180$) — the angle of the $i$-th rotation in degrees.
     34 
     35 Output
     36 
     37 If it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word "YES". Otherwise, print "NO". Petr will probably buy a new car in this case.
     38 
     39 You can print each letter in any case (upper or lower).
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 3
     47 10
     48 20
     49 30
     50 ```
     51 
     52 Output
     53 
     54 ```
     55 YES
     56 ```
     57 
     58 Input
     59 
     60 ```
     61 3
     62 10
     63 10
     64 10
     65 ```
     66 
     67 Output
     68 
     69 ```
     70 NO
     71 ```
     72 
     73 Input
     74 
     75 ```
     76 3
     77 120
     78 120
     79 120
     80 ```
     81 
     82 Output
     83 
     84 ```
     85 YES
     86 ```
     87 
     88 Note
     89 
     90 In the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.
     91 
     92 In the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.
     93 
     94 In the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.