博客
关于我
Bear and Poker CodeForces - 573A
阅读量:259 次
发布时间:2019-03-01

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

题意:给n个数,可以把某个数乘3或者某个数乘2任意次。问是否有可能把所有数变得相同。

题解:如果可以,那这些数一定可以写成2^x*3^y*z,显然我们只需要判断这些数的z是否相同就可以了。扩展一下:所有数都可以写成 2 ^a·3^b·5 ^c·7^ d...的形式。

AC代码:

#include 
#include
#include
#include
#include
#include
#include
#define int long long#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);using namespace std;const int maxn=1e6+5;int a[maxn];int root(int x) { while(x%2==0)x/=2; while(x%3==0)x/=3; return x;}main() { int n; cin>>n; for(int i=1; i<=n; i++)cin>>a[i]; int flag=1; int num=root(a[1]); for(int i=2; i<=n; i++)if(num!=root(a[i]))flag=0; if(flag)cout<<"YES"<

 

转载地址:http://tdnt.baihongyu.com/

你可能感兴趣的文章
Mysql:避免重复的插入数据方法汇总
查看>>
m_Orchestrate learning system---二十二、html代码如何变的容易
查看>>
n = 3 , while n , continue
查看>>
n 叉树后序遍历转换为链表问题的深入探讨
查看>>
N-Gram的基本原理
查看>>
nacos config
查看>>
Nacos 与 Eureka、Zookeeper 和 Consul 等其他注册中心的区别
查看>>
Nacos2.X 配置中心源码分析:客户端如何拉取配置、服务端配置发布客户端监听机制
查看>>
NacosClient客户端搭建,微服务注册进nacos
查看>>
Nacos原理
查看>>
Nacos发布0.5.0版本,轻松玩转动态 DNS 服务
查看>>
Nacos启动异常
查看>>
Nacos和Zookeeper对比
查看>>
Nacos在双击startup.cmd启动时提示:Unable to start embedded Tomcat
查看>>
Nacos如何实现Raft算法与Raft协议原理详解
查看>>
Nacos安装教程(非常详细)从零基础入门到精通,看完这一篇就够了
查看>>
Nacos实战攻略:从入门到精通,全面掌握服务治理与配置管理!(下)
查看>>
Nacos心跳机制实现快速上下线
查看>>
Nacos服务注册与发现demo
查看>>
nacos服务注册流程
查看>>