codeforces-scrape

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

573A.md (1381B)


      1 Source: https://codeforces.com/problemset/problem/573/A
      2 
      3 A. Bear and Poker
      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 Limak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are *n* players (including Limak himself) and right now all of them have bids on the table. *i*-th of them has bid with size *a**i* dollars.
     22 
     23 Each player can double his bid any number of times and triple his bid any number of times. The casino has a great jackpot for making all bids equal. Is it possible that Limak and his friends will win a jackpot?
     24 
     25 Input
     26 
     27 First line of input contains an integer *n* (2 ≤ *n* ≤ 105), the number of players.
     28 
     29 The second line contains *n* integer numbers *a*1, *a*2, ..., *a**n* (1 ≤ *a**i* ≤ 109) — the bids of players.
     30 
     31 Output
     32 
     33 Print "Yes" (without the quotes) if players can make their bids become equal, or "No" otherwise.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 4  
     41 75 150 75 50
     42 ```
     43 
     44 Output
     45 
     46 ```
     47 Yes
     48 ```
     49 
     50 Input
     51 
     52 ```
     53 3  
     54 100 150 250
     55 ```
     56 
     57 Output
     58 
     59 ```
     60 No
     61 ```
     62 
     63 Note
     64 
     65 In the first sample test first and third players should double their bids twice, second player should double his bid once and fourth player should both double and triple his bid.
     66 
     67 It can be shown that in the second sample test there is no way to make all bids equal.