博客
关于我
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/

你可能感兴趣的文章
NFV商用可行新华三vBRAS方案实践验证
查看>>
ng build --aot --prod生成文件报错
查看>>
ng 指令的自定义、使用
查看>>
ng6.1 新特性:滚回到之前的位置
查看>>
nghttp3使用指南
查看>>
Nginx
查看>>
nginx + etcd 动态负载均衡实践(一)—— 组件介绍
查看>>
nginx + etcd 动态负载均衡实践(三)—— 基于nginx-upsync-module实现
查看>>
nginx + etcd 动态负载均衡实践(二)—— 组件安装
查看>>
nginx + etcd 动态负载均衡实践(四)—— 基于confd实现
查看>>
Nginx + Spring Boot 实现负载均衡
查看>>
Nginx + Tomcat + SpringBoot 部署项目
查看>>
Nginx + uWSGI + Flask + Vhost
查看>>
Nginx - Header详解
查看>>
Nginx - 反向代理、负载均衡、动静分离、底层原理(案例实战分析)
查看>>
Nginx - 反向代理与负载均衡
查看>>
nginx 1.24.0 安装nginx最新稳定版
查看>>
nginx 301 永久重定向
查看>>
nginx connect 模块安装以及配置
查看>>
nginx css,js合并插件,淘宝nginx合并js,css插件
查看>>