博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CF #318 C. Bear and Poker
阅读量:6543 次
发布时间:2019-06-24

本文共 2111 字,大约阅读时间需要 7 分钟。

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.

1 #include 
2 #include
3 #include
4 using namespace std; 5 6 int gcd(int a,int b) 7 { 8 if(a
1)32 {33 if(x%2==0)34 x=x/2;35 else if(x%3==0)36 x=x/3;37 else38 {39 flg=0;40 break;41 }42 }43 while(y>1)44 {45 if(y%2==0)46 y=y/2;47 else if(y%3==0)48 y=y/3;49 else50 {51 flg=0;52 break;53 }54 }55 if(flg==0)56 break;57 }58 if(flg==1)59 printf("Yes\n");60 else61 printf("No\n");62 return 0;63 }
View Code

 

转载于:https://www.cnblogs.com/cyd308/p/4770802.html

你可能感兴趣的文章
2011/7/3 第二次评审
查看>>
Openvswitch手册(2): OpenFlow Controller
查看>>
tar解压
查看>>
inheritprototype原型继承封装及综合继承最简实例
查看>>
【磁耦隔离接口转换器】系列产品选型指南
查看>>
Apriori 关联算法学习
查看>>
二叉树、红黑树、伸展树、B树、B+树
查看>>
Junit核心——测试集(TestSuite)
查看>>
MVPArms官方首发一键生成组件化,体验纯傻瓜式组件化开发
查看>>
Log4j_学习_00_资源帖
查看>>
制作iso镜像U盘自动化安装linux系统
查看>>
JSLint的使用
查看>>
命令行常用命令--软连接
查看>>
HTTP POST GET 本质区别详解
查看>>
OC继承专题
查看>>
PHP中HASH函数的优化技巧
查看>>
MD5加密
查看>>
RSA算法实例
查看>>
ant
查看>>
微信,想要说爱你,却没有那么容易!
查看>>