博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2)C. Bear and Poker
阅读量:5010 次
发布时间:2019-06-12

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

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

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,问你是否能让所有数相同;

题解:先找出最大公约数,再不断除2,3,判断是否是1就好了

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
typedef __int64 ll;#define inf 0x7fffffffusing namespace std;inline ll read(){ ll x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); } return x*f;}//**************************************************************************************ll gcd(ll a,ll b){ if(b==0)return a; else return gcd(b,a%b);}int A[100005];int main(){ int n=read(); ll a=read(); int cnt=0; A[++cnt]=a; for(int i=1;i
代码

 

转载于:https://www.cnblogs.com/zxhl/p/4770406.html

你可能感兴趣的文章
RegEx正则表达式学习笔记
查看>>
LeetCode:3Sum
查看>>
[转]申瓯 JSY2000-06 程控电话交换机呼叫转移设置
查看>>
Javascript----input事件实现动态监听textarea内容变化
查看>>
【语言处理与Python】1.1文本和单词
查看>>
字符串尾号数字自增长
查看>>
ASP.NET Core中使用xUnit进行单元测试
查看>>
在桌面添加快捷方式
查看>>
字符串反转
查看>>
DirectX9 里HLSL的语义Semantics
查看>>
linux shell 发送email 附件
查看>>
人群密度估计 CrowdCount
查看>>
京东为什么不会死
查看>>
JSON.parse()和JSON.stringify()
查看>>
清北学堂 day6 兔子
查看>>
Enabling button in SubGrid on selection of record (SelectionCountRule) in CRM 2011(abstract)
查看>>
.net 常用正则表达式
查看>>
JAVA动态代理机制解析
查看>>
浏览器样式(css)兼容
查看>>
Java泛型中的标记符含义:
查看>>