CF #318 (Div. 2) C. Bear and Poker 唯一分解定理
来源:互联网 发布:win7服务器端口开放 编辑:程序博客网 时间:2024/06/15 08:34
http://codeforces.com/contest/574/problem/C
题意:给你m个数,判断这些数能否通过乘以2或者乘以3最后变成同一个数;
分析:素数唯一分解定理,即对于一个任意的数字m都可以转化成m=a^p1*b^p2...,,a,b,均是素数且这个分解是#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
#define MM(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef unsigned long long ULL;
const int mod = 1000000007;
const double eps = 1e-10;
const int inf = 0x3f3f3f3f;
const int big=50000;
int a[100005];
int main()
{
int n;
while(~scanf("%d",&n))
{
int flag=1;
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
int temp=a[i];
while(temp%2==0||temp%3==0)
{
if(temp%2==0)
temp/=2;
else if(temp%3==0)
temp/=3;
}
if(i!=1&&temp!=a[i-1])
flag=0;
else a[i]=temp;
}
if(flag)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return 0;
}
唯一确定的。然后逆向思考
阅读全文
0 0
- CF #318 (Div. 2) C. Bear and Poker 唯一分解定理
- Codeforces Round #318 (Div. 2) C - Bear and Poker
- CodeForce #318 div 2 C Bear and Poker
- CF#318-C - Bear and Poker-大水题t
- Codeforces Round #318 (Div. 2) Bear and Poker
- Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2)C. Bear and Poker(gcd模拟)
- Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2)C Bear and Poker
- Codeforces Round #318 C - Bear and Poker
- Codeforces Round #318-(C. Bear and Poker)
- CF 573A(Bear and Poker-GCD)
- CF# IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2) C - Bear and Up-Down
- CodeForces 574C - Bear and Poker
- Codeforces 574C Bear and Poker【思维】
- CodeForces #318 (div1) A.Bear and Poker
- Codeforces Round #318 Bear and Poker(数学题)
- Bear and Poker
- A. Bear and Poker
- Bear and Poker CodeForces
- git中checkout前后的branch变化
- 修改FMRadio频率的工作范围
- poj 1201 Intervals 线段树+贪心
- hdu 2602 Bone Collector 0-1背包;
- openssl与数字证书的使用
- CF #318 (Div. 2) C. Bear and Poker 唯一分解定理
- 深入理解mybatis原理(五) MyBatis缓存机制的设计与实现
- CF#318 (Div. 2)B. Bear and Three Musketeers 暴力 复杂度分析
- hdu 1421
- poj 3041 Asteroids 二分匹配 匈牙利算法 模板题
- poj 3281 Dining 最大流dinic 模板题
- poj 3469 Dual Core CPU 最大流建图思想 dinic 弧优化很重要
- poj 2135 Farm Tour 最小费用流 spfa优化 16_05_14
- poj 3686 The Windy\'s 最小费用流 建图 16_05_14