只需A的全部质因数包含在B中即可。

#include <iostream>
#include <cstdio>
#define LL __int64
#include <algorithm>
using namespace std; LL gcd(LL a,LL b){
if (b==0)
return a;
return gcd(b,a%b);
} int main(){
int T,kase=0;
LL A,B;
scanf("%d",&T);
while(T--){
scanf("%I64d%I64d",&A,&B);
LL g=gcd(A,B);
LL t=A/g;
LL tmp=gcd(g,t);
while(1!=tmp){
t/=tmp;
tmp=gcd(g,t);
}
if(t==1)
printf("Case #%d: YES\n",++kase);
else printf("Case #%d: NO\n",++kase);
}
}

  

HDU 4320 Contest 3的更多相关文章

  1. HDU 4320 Arcane Numbers 1 (数论)

    A - Arcane Numbers 1 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64 ...

  2. HDU 4320 Arcane Numbers 1(质因子包含)

    http://acm.hdu.edu.cn/showproblem.php?pid=4320 题意: 给出A,B,判断在A进制下的有限小数能否转换成B进制下的有限小数. 思路: 这位博主讲得挺不错的h ...

  3. HDU 5045 Contest(状压DP)

    Problem Description In the ACM International Collegiate Programming Contest, each team consist of th ...

  4. hdu - 5045 - Contest(国家压缩dp)

    意甲冠军:N个人M通过主打歌有自己的期望,每个问题发送人玩.它不能超过随机播放的次数1,追求最大业绩预期 (1 ≤ N ≤ 10,1 ≤ M ≤ 1000). 主题链接:pid=5045" ...

  5. [ACM] hdu 5045 Contest (减少国家Dp)

    Contest Problem Description In the ACM International Collegiate Programming Contest, each team consi ...

  6. HDU–5988-Coding Contest(最小费用最大流变形)

    Coding Contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  7. HDU 4320 Arcane Numbers 1 (质因子分解)

    题目:传送门. 题意:将一个A进制下的有限小数转化为B进制看是否仍为有限小数. 题解:一个A进制的小数可以下次 左移动n位变成A进制整数然后再将其转化为B进制即可 即B^m/A^n要整除,因此A的质因 ...

  8. hdu 5045 Contest(状态压缩DP)

    题解:我们使用一个二位数组dp[i][j]记录进行到第i个任务时,人组合为j时的最大和(这里的j我们用二进制的每位相应一个人). 详细见代码: #include <iostream> #i ...

  9. HDU 5045 Contest

    pid=5045">主题链接~~> 做题感悟:比赛时这题后来才写的,有点小尴尬.两个人商议着写写了非常久才写出来,I want to Powerful ,I believe me ...

随机推荐

  1. SDUT OJ 1124 飞越原野 (三维BFS练习)

    飞跃原野 nid=24#time" title="C.C++.go.haskell.lua.pascal Time Limit5000ms Memory Limit 65536K ...

  2. mysql安装出错cannot create windows service for mysql.error:0

    配置时最后一步出现不能启动mysql 解决成功的办法:[MySQL] Could not start the service MySQL 解决方法 安装mysql 5.1.33,在运行Server I ...

  3. ExtJs--16--Ext.override()方法专门用来重写对象的方法

    Ext.onReady(function(){ /** * Ext.override()方法专门用来重写对象的方法 */ //定义个类 Ext.define("U",{ //该类的 ...

  4. 2017-3-6 leetcode 118 169 189

    今天什么都没发生 ================================================= leetcode118 https://leetcode.com/problems ...

  5. 操作系统-容器-引擎容器-百科:Docker

    ylbtech-操作系统-容器-引擎容器-百科:Docker Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上 ...

  6. 8.QList QMap QVariant

    QList int main1(int argc, char *argv[]) { QApplication a(argc, argv); QList<,,}; mylist << ...

  7. MySQL 5.6.26 通过frm & ibd 恢复数据过程

    在A服务器上创建数据库yoonroot(yoon)> show create table yoon\G*************************** 1. row *********** ...

  8. Incorrect integer value: '' for column 'RegNum' at row 1

    数据库版本: 5.6.16​​操作系统: Red Hat Enterprise Linux Server release 6.3 (Santiago)​​在插入数据的时候提示告警:​mysql> ...

  9. hdu 1754 I Hate It【线段树】

    维护一个最大值 #include<cstdio> #include<cstring> #include<iostream> #include<algorith ...

  10. 关于<marquee>、<form>、input中的<text>、<password>、<hidden>、<wenbenkuang>、<reset>、<image>、<submit>、<radio>、<checkbox>以及<select><iframe src>的用法

    <html>    <head>        <meta charset="UTF-8">        <title></ ...