hdu 4320 Arcane Numbers 1 多校联合赛(三)第一题
2012-08-06 14:58
344 查看
“对于所有的 x|a, 有 x|A”。
能够在进制 A 下用有限数位表示的任何一个有理数.
其最简分母 (a) 和进制数 (A) 肯定能满足上面的“充要条件”。
也就是说,这些有理数的最简分母,都可以表示成 A 的若干个因子相乘的形式
(相同因子可乘多次)。
那么如果要保证这些有理数在进制 B 下也能顺利用有限数位表示的话,
B 这个数的因子必须至少要包含 A 中的因子。
看到这题目谁想的到啊!
View Code
Arcane Numbers 1
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1719 Accepted Submission(s): 539
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.
Output
For each case, output “NO” if Vance will win the game. Otherwise, print “YES”. See Sample Output for more details.
Sample Input
3
5 5
2 3
1000 2000
Sample Output
Case #1: YES
Case #2: NO
Case #3: YES
能够在进制 A 下用有限数位表示的任何一个有理数.
其最简分母 (a) 和进制数 (A) 肯定能满足上面的“充要条件”。
也就是说,这些有理数的最简分母,都可以表示成 A 的若干个因子相乘的形式
(相同因子可乘多次)。
那么如果要保证这些有理数在进制 B 下也能顺利用有限数位表示的话,
B 这个数的因子必须至少要包含 A 中的因子。
看到这题目谁想的到啊!
View Code
#include <stdio.h> #include <string.h> int main() { __int64 a,b,ans,i,t,cas; scanf("%I64d",&t); for(cas=1;cas<=t;cas++) { printf("Case #%d: ",cas); ans=1; scanf("%I64d%I64d",&a,&b); for(i=2;i*i<=a;i++) { if(a%i==0) { ans*=i; while(a%i==0) a/=i; } } ans*=a; if(b%ans==0) printf("YES\n"); else printf("NO\n"); } return 0; }
Arcane Numbers 1
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1719 Accepted Submission(s): 539
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.
Output
For each case, output “NO” if Vance will win the game. Otherwise, print “YES”. See Sample Output for more details.
Sample Input
3
5 5
2 3
1000 2000
Sample Output
Case #1: YES
Case #2: NO
Case #3: YES
相关文章推荐
- hdu 4320 Arcane Numbers 1 多校联合赛(三)第一题
- HDU 4320 Arcane Numbers 1 (数论)
- HDU 4320 Arcane Numbers 1(12年多校3-数学)
- 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 (数论)
- HDU 4320 Arcane Numbers 1
- hdu 4320 Arcane Numbers 1(小数进制转化后是否有限位)
- HDU 4320 - Arcane Numbers 1 / SWUN 1429 - 进制转化
- 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
- HDU - 4320 Arcane Numbers 1
- HDU 4320 Arcane Numbers 1
- hdu - 4320 - Arcane Numbers 1 - 想法题
- hdu 4300 Clairewd’s message kmp匹配! 多校联合赛第一题