10
16
2015
0

[Codeforces Round #318] Bear and Poker


C. Bear and Poker
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 ai dollars.

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?

Input

First line of input contains an integer n (2 ≤ n ≤ 105), the number of players.

The second line contains n integer numbers a1, a2, ..., an (1 ≤ ai ≤ 109) — the bids of players.

Output

Print "Yes" (without the quotes) if players can make their bids become equal, or "No" otherwise.

Sample test(s)
input
4
75 150 75 50
output
Yes
input
3
100 150 250
output
No
Note

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.

It can be shown that in the second sample test there is no way to make all bids equal.

题目大意:给出n个数,问是否可以把这些数分别乘以若干个2或3,使得它们相等。


根据唯一分解定理,一个数可以被写成这样的形式$x=p_1^{a_1}+p_2^{a_2}+...+p_k^{a_k}$($p_i$为质数)。把一个数乘2或乘3只会改变2或3上的指数,不可能改变别的指数,所以只要所有给出的数除去质因数2和3后都相等,就可以通过乘2和乘3使它们相等。

代码在此。

Category: 题解 | Tags: 数学 Codeforces 数论 | Read Count: 398

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com