A. Bear and Poker

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/573/problem/A

Description

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 Input

4
75 150 75 50

Sample Output

Yes

HINT

题意

给你n个数,你可以把操作任意一个数,使他翻倍或者翻三倍无数次,问你是否可以让所有数都相同

题解

假设最后变成了K,那么K=2^x+3^y+tmp

所以把所有数都按照2和3分解之后,只要剩下的数都是tmp,那就是yes

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <bitset>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200051
#define mod 10007
#define eps 1e-9
int Num;
//const int inf=0x7fffffff; //нчоч╢С
const int inf=0x3f3f3f3f;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** ll a[maxn];
int check(ll x)
{
if(x==)
return ;
if(x==)
return ;
if(x==)
return ;
if(x%==)
return check(x/);
if(x%==)
return check(x/);
return ;
}
int n;
ll gcd(ll a,ll b)
{
return b==?a:gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
return a*b/gcd(a,b);
}
int main()
{
n=read();
for(int i=;i<n;i++)
a[i]=read();
sort(a,a+n);
ll tmp = a[];
for(int i=;i<n;i++)
{
tmp = gcd(tmp,a[i]);
}
for(int i=;i<n;i++)
{
if(!check(a[i]/tmp))
{
cout<<"No"<<endl;
return ;
}
}
cout<<"Yes"<<endl;
}

Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1) A. Bear and Poker 分解的更多相关文章

  1. Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1) B. Bear and Blocks 水题

    B. Bear and Blocks Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/573/pr ...

  2. Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1) C. Bear and Drawing

    题目链接:http://codeforces.com/contest/573/problem/C题目大意:在两行无限长的点列上面画n个点以及n-1条边使得构成一棵树,并且要求边都在同一平面上且除了节点 ...

  3. 校内选拔I题题解 构造题 Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2) ——D

    http://codeforces.com/contest/574/problem/D Bear and Blocks time limit per test 1 second memory limi ...

  4. Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2) A. Bear and Elections 优先队列

                                                    A. Bear and Elections                               ...

  5. Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2) B. Bear and Three Musketeers 枚举

                                          B. Bear and Three Musketeers                                   ...

  6. Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2)C. Bear and Poker

                                                  C. Bear and Poker                                     ...

  7. Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2)

    以后每做完一场CF,解题报告都写在一起吧   暴力||二分 A - Bear and Elections 题意:有n个候选人,第一个候选人可以贿赂其他人拿到他们的票,问最少要贿赂多少张票第一个人才能赢 ...

  8. Codeforces Round #318 (Div. 2) C Bear and Poker (数学)

    简单题,求一下所有数的2和3的幂是任意调整的,把2和3的因子除掉以后必须相等. 求lcm,爆了long long.我得好好反省一下,对连乘不敏感 #include<bits/stdc++.h&g ...

  9. Codeforces Round #539&#542&#543&#545 (Div. 1) 简要题解

    Codeforces Round #539 (Div. 1) A. Sasha and a Bit of Relax description 给一个序列\(a_i\),求有多少长度为偶数的区间\([l ...

随机推荐

  1. Oracle日常维护脚本

    1.正常停库流程     ps -ef|grep LOCAL=NO|cut -c 9-15|xargs kill -9      shutdown immediate; 2.备份数据库     bac ...

  2. source insight 的使用

    一,新建工程:project-->new project --> ok--> ok--> close 完成项目的添加 二,sourceInsight的使用 1.跳转到标识定义处 ...

  3. storm入门教程 第四章 消息的可靠处理【转】

    4.1 简介 storm可以确保spout发送出来的每个消息都会被完整的处理.本章将会描述storm体系是如何达到这个目标的,并将会详述开发者应该如何使用storm的这些机制来实现数据的可靠处理. 4 ...

  4. jenkins 命令行 CLI jenkins-cli.jar

    部署好jenkins后,一般都是通过jenkins提供的web界面来操作jenkins. 而有些场景则需要通过命令来操作jenkins,例如通过脚本操作jenkins. 在jenkins提供的web界 ...

  5. PHP 系统命令函数

    function execute($cmd) { $res = ''; if ($cmd) { if(function_exists('system')) { @ob_start(); @system ...

  6. 告别where 1=1 最佳方案分享

    已经有2年没有用过where 1=1了,没想到换了家公司后,又让我看到了它.在网络上面搜索了一下,发现没有人提供一个比较好的方案来解决这一问题.很多人说可以让数据库的优化机制去处理,但是,我想对于大部 ...

  7. exists与in的使用与区别

    1.in的使用举例 select * from tableA where id in (select id from tableB) 2.exists的使用举例 select * from table ...

  8. bzoj 3620 似乎在梦中见过的样子(KMP)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3620 [题意] 给定一个字符串,统计有多少形如A+B+A的子串,要求A>=K,B ...

  9. Azure终于支持大容量虚拟机了-最高32核,448G内存

    Azure终于支持大容量虚拟机了-最高32核,448G内存 最近微软Azure虚拟机旗下的大容量G系列虚拟机通用版本正式上线.G系列虚拟机方案提供公有云领域最大的内存容量.最强处理能力以及空间可观的本 ...

  10. 【更新sql server数据项的长度】////【复制数据到另一张表中】

    由于设计时没考虑周全,之后发现长度不够,手动修改又不可以... 重新新建也不行啊>>>>>>>>>里面的数据怎么办 so:直接用代码了.... a ...