质因数:arcane number1
来源:互联网 发布:k30平板荷载试验算法 编辑:程序博客网 时间:2024/06/05 03:58
Arcane Numbers 1
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1687 Accepted Submission(s): 528
Problem Description
Vance and Shackler like playing games. One day, they are playing a game called "arcane numbers". The game is pretty simple, Vance writes down a finite decimal under base A, and then Shackler translates it under base B. If Shackler can translate it into a finite decimal, he wins, else it will be Vance’s win. Now given A and B, please help Vance to determine whether he will win or not. Note that they are playing this game using a mystery language so that A and B may be up to 10^12.
Input
The first line contains a single integer T, the number of test cases.
For each case, there’s a single line contains A and B.
For each case, there’s a single line contains A and B.
Output
For each case, output “NO” if Vance will win the game. Otherwise, print “YES”. See Sample Output for more details.
Sample Input
35 52 31000 2000
Sample Output
Case #1: YESCase #2: NOCase #3: YES
Author
Vance and Shackler
Source
2012 Multi-University Training Contest 3
Recommend
zhoujiaqi2010
n进制的小数,是n的k次方分之一的小数的组合,k从1到无穷大
如果a有的质因数b没有,则a无法用b表示
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cmath>using namespace std;int const maxm=1009999;int prime[maxm];long long pri[maxm];int sum;void sievePrime(){ //筛法打素数表 int j; int i; for(i=0;i<maxm;i++) prime[i]=1; prime[0]=0; prime[1]=0; int max=sqrt(maxm*1.0); for(i=2;i<=max;i++) { if(prime[i]) for(j=i+i;j<maxm;j=j+i) { prime[j]=0; } } for(i = 0, j = 0; i < maxm; i ++){ if(prime[i]){ pri[j++] = i; } } sum = j;}int main(){ int t; int i, j; long long a, b; int cnt = 0; sievePrime(); scanf("%d", &t); while(t --){ cnt ++; scanf("%I64d %I64d", &a, &b); bool flag = true; for(i = 0; i < sum && pri[i] <= a; i ++){ if(a % pri[i] == 0){ if(b % pri[i]){ flag = false; break; } while(a % pri[i] == 0){ a /= pri[i]; } } } if(a != 1 && b % a != 0){ //a中有可能还包含b中没有的质因数 flag = false; } printf("Case #%d: ", cnt); if(flag) printf("YES\n"); else printf("NO\n"); } return 0;}
- 质因数:arcane number1
- number1
- POJ3614-number1
- 深入理解计算机系统 Number1
- Array--Find Number1
- cocos2dx-练习number1
- 质因数
- 质因数
- 质因数
- 质因数
- 质因数
- hdu 4320 Arcane Numbers 1
- hdu 4320 Arcane Numbers 1
- HDU - 4320 Arcane Numbers 1
- HDU 4320 Arcane Numbers 1
- HDU 4320 Arcane Numbers 1
- Swift函数参数 test(number1 num1:Int,number2 num2:Int),test(number1: 3, number2: 5)
- Cool Stuff with Delphi #16 -- Arcane Fractals
- panda3d 解决ShowBase和DirectObject之间冲突的代码
- C语言变量声明加冒号的用法
- js正则表达式的特殊字符
- 《百家讲坛》之战国七雄
- [网络流] 最大流 最小费 回顾
- 质因数:arcane number1
- (二)上传图片至服务器,写入到数据库Blob字段中,以及从数据库读取Blob信息(iframe父子页面传值)
- 变参函数和va_list
- portage一些概要
- ajax之服务器端的 JSON
- Linux定时器的使用
- 《jsp连接数据库大全》
- group by havding order by
- ios中的图标