C. The Meaningless Game
C. The Meaningless Game
题意
给你两个数,开始都为1,然后每轮可以任选一个k,一边可以乘以\(k\),另一边乘以\(k^2\),然后问你最终是否可以得到所给的两个数a,b;
思路
\(a×b = t^3\),二分是否存在\(t\),如果不存在肯定不可以,如果存在,那么要保证a中有t中所有的因子,b中也是,那么就是$ amodt==0 and bmodt == 0\(,因为\)t = k1k2...kn\(,那么\)a\(中要么是\)k1^2\(要么是\)k1\(,同理\)b$
代码
#include<bits/stdc++.h>
#define N 100005
using namespace std;
typedef long long LL;
LL gcd(LL n,LL m);
int main(void)
{
int T;
scanf("%d",&T);
while(T--)
{
LL a,b;
scanf("%lld %lld",&a,&b);
LL c = a*b;
LL l = 0,r = 1000000;
LL id;
while(l <= r)
{
LL mid = (l+r)/(LL)2;
if(mid*mid*mid <= a*b)
{
l = mid + 1;
id = mid;
}
else r = mid - 1;
}
if(id*id*id != a*b)
{
printf("No\n");
}
else
{ //aprintf("%d\n",id);
if(!(a%id)&&!(b%id))
printf("Yes\n");
else printf("No\n");
}
}
return 0;
}
LL gcd(LL n,LL m)
{
if(m == 0)
return n;
else return gcd(m,n%m);
}
C. The Meaningless Game的更多相关文章
- Cassandra - Non-system keyspaces don't have the same replication settings, effective ownership information is meaningless
In cassandra 2.1.4, if you run "nodetool status" without any keyspace specified, you will ...
- C. Meaningless Operations Codeforces Global Round 1 异或与运算,思维题
C. Meaningless Operations time limit per test 1 second memory limit per test 256 megabytes input sta ...
- Codeforces 833A The Meaningless Game - 数论 - 牛顿迭代法 - 二分法
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting. T ...
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
C. The Meaningless Game 题意: 两个人刚刚开始游戏的时候的分数, 都是一分, 然后随机一个人的分数扩大k倍,另一个扩大k的平方倍, 问给你一组最后得分,问能不能通过游戏得到这样 ...
- Codeforces 834C - The Meaningless Game
834C - The Meaningless Game 数学. 思路1:判断a•b能不能化成v3且a%v==0且b%v==0.v可以直接用pow求(或者用cbrt),也可以二分求:还可以用map映射预 ...
- A. The Meaningless Game(数学)
A. The Meaningless Game time limit per test:1 second memory limit per test:256 megabytes input:stand ...
- Codeforces Round #426 The Meaningless Game
题目网址:http://codeforces.com/contest/834/problem/C 题目: C. The Meaningless Game Slastyona and her loyal ...
- CodeForces 834C - The Meaningless Game | Codeforces Round #426 (Div. 2)
/* CodeForces 834C - The Meaningless Game [ 分析,数学 ] | Codeforces Round #426 (Div. 2) 题意: 一对数字 a,b 能不 ...
- MDK中问题:warning : type qualifier is meaningless on cast type return 的解决
在MDK编译代码时,有时会出现这样的警告, warning : type qualifier is meaningless on cast type return 在MDK中,作如下设置: 即添加 : ...
- The meaningless Game
题目 Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting ...
随机推荐
- ubuntu常见错误--Could not get lock /var/lib/dpkg/lock
ubuntu常见错误--Could not get lock /var/lib/dpkg/lock 通过终端安装程序sudo apt-get install xxx时出错: E: Could ...
- A Child's History of England.6
It was a British Prince named Vortigern who took this resolution, and who made a treaty of friendshi ...
- A Child's History of England.13
Then came the boy-king, Edgar, called the Peaceful, fifteen years old. Dunstan, being still the real ...
- Scala和Java的List集合互相转换
import java.util import scala.collection.mutable /** * 集合互相转换 */ object ScalaToJava { def main(args: ...
- 自定义控件CustomAlertView
[记录][完整代码最下] 效果如下: 可行性分析: 由于系统自带的UIAlertView样式简单,只有两种样式,想要理想的样式就要自定义控件了 文件名取为:CustomAlertView 创建文件如下 ...
- 100个Shell脚本——【脚本7】批量建立用户
[脚本7]批量建立用户 编写shell脚本,批量建立用户user_00, user_01, ... user_100并且所有用户同属于users组. 一.脚本 #!/bin/bash group=`c ...
- git 日志技术
1.git log, 在一个分支下, 以时间的倒序方式显示你制造的所有commit列表,包含创建人,时间,提交了什么等信息: 2. git reflog, 获取您在本地repo上还原commit所做工 ...
- 数据库SQL性能优化
1.in与exists的效率比较 in是把外表和内表作hash 连接,而exists 是对外表作loop 循环,每次loop 循环再对内表进行查询.一直以来认为exists 比in 效率高的说法是不准 ...
- 在隐藏导航栏的控制器中,调用UIIMagePickerController,出现导航栏变透明的问题
在隐藏导航栏的控制器中,调用UIIMagePickerController,出现导航栏变透明的问题 解决办法 #pragma mark - UIImagePickerController Delega ...
- oracle keep
语法: min | max(column1) keep (dense_rank first | last order by column2) over (partion by column3); -- ...