2012 #3 Arcane Numbers
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
Input
For each case, there’s a single line contains A and B.
Output
Sample Input
5 5
2 3
1000 2000
Sample Output
Case #2: NO
Case #3: YES
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; long long gcd(long long a,long long b)
{
if(a<b)
return gcd(b,a);
else if(b==)
return a;
else
return gcd(b,a%b);
} int main()
{
int T,ca=;
long long A,B;
int i,j,k,flg;
scanf("%d",&T);
while(T--)
{
scanf("%I64d %I64d",&A,&B);
long long C=gcd(A,B),D;
A=A/C,B=B/C;
flg=;
if(B>)
{
while()
{
if(B==)
break;
D=gcd(B,C);
if(D==)
{
flg=;
break;
}
B=B/D;
}
}
if(A>)
{
while()
{
if(A==)
break;
D=gcd(A,C);
if(D==)
{
flg=;
break;
}
A=A/D;
}
}
if(flg==)
printf("Case #%d: YES\n",ca);
else
printf("Case #%d: NO\n",ca);
ca++;
}
return ;
}
2012 #3 Arcane Numbers的更多相关文章
- HDU 4320 Arcane Numbers 1 (数论)
A - Arcane Numbers 1 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64 ...
- Arcane Numbers 1
Vance and Shackler like playing games. One day, they are playing a game called "arcane numbers& ...
- HDU 4320 Arcane Numbers 1 (质因子分解)
题目:传送门. 题意:将一个A进制下的有限小数转化为B进制看是否仍为有限小数. 题解:一个A进制的小数可以下次 左移动n位变成A进制整数然后再将其转化为B进制即可 即B^m/A^n要整除,因此A的质因 ...
- HDU 4320 Arcane Numbers 1(质因子包含)
http://acm.hdu.edu.cn/showproblem.php?pid=4320 题意: 给出A,B,判断在A进制下的有限小数能否转换成B进制下的有限小数. 思路: 这位博主讲得挺不错的h ...
- 数论(GCD) HDOJ 4320 Arcane Numbers 1
题目传送门 题意:有一个A进制的有限小数,问能否转换成B进制的有限小数 分析:0.123在A进制下表示成:1/A + 2/(A^2) + 3 / (A^3),转换成B进制就是不断的乘B直到为0,即(1 ...
- HDU 4321 Arcane Numbers 2
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4321 ----------------------------------------------- ...
- 2012多校3.A(用O(log(n))判断b^k % a == 0)
Arcane Numbers 1 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Su ...
- 59. 总结篇:数组中N(n=1,2,3)个只出现一次的数字[find N numbers which appear only once in array]
[本文链接] http://www.cnblogs.com/hellogiser/p/find-n-numbers-which-appear-only-once-in-array.html [题目] ...
- Overview of Form Control Types [AX 2012]
Overview of Form Control Types [AX 2012] Other Versions 0 out of 1 rated this helpful - Rate this to ...
随机推荐
- Java图像文件的读写
读取bmp文件到BufferedImage中File file2 = new File("c:\\testimages\\tttt" + ".bmp");// ...
- jQuery触发<a>标签的点击事件后URL不跳转的解决办法
有HTML代码如下: <a id="workFrame" href="pages/work.html" target="FrameBox&quo ...
- android 应用架构随笔三(ListView)
import java.util.ArrayList; import java.util.List; import com.heima.googleplay.holder.BaseHolder; im ...
- Linux USB摄像头驱动【转】
本文转载自:http://www.itdadao.com/articles/c15a509940p0.html 在 cortex-a8 中,可接入摄像头的接口通常可以分为两种, CAMERA 接口和 ...
- 用grunt搭建自动化的web前端开发环境实战教程(详细步骤)
用grunt搭建自动化的web前端开发环境实战教程(详细步骤) jQuery在使用grunt,bootstrap在使用grunt,百度UEditor在使用grunt,你没有理由不学.不用!前端自动化, ...
- React笔记_(2)_react语法1
这一节内容主要以了解为主. 渐渐的体会react的语法和其特性. ① htmlAndJs 混合编写 react和以往的前后台书写方式不一样. 在之前的多个语言中,讲求的是将页面代码和js代码逻辑分开, ...
- SQL SERVER 2008 中三种分页方法与总结
建立表: CREATE TABLE [TestTable] ( , ) NOT NULL , ) COLLATE Chinese_PRC_CI_AS NULL , ) COLLATE Chinese_ ...
- 免安装版Tomcat6.0启动方法
免安装版Tomcat6.0启动方法 1.下载Tomcat Zip压缩包,解压. 2.修改startup.bat文件: 在第一行前面加入如下两行 SET JAVA_HOME=JDK目录 SET CATA ...
- mysql-5.5.28源码安装过程中错误总结
介绍一下关于mysql-5.5.28源码安装过程中几大错误总结,希望此文章对各位同学有所帮助.系统centOS 6.3 mini (没有任何编译环境)预编译环境首先装了众所周知的 cmake(yum ...
- jQuery.isNumeric() 和 js isNaN()
jQuery.isNumeric( value ) Description: 判断指定参数是否是一个数字值(字符串形式的数字也符合条件),返回 true 或者 false. Example: $.is ...