Arcane Numbers 1Time
limit:1000MS
Memory Limit:32768KB
64bit IO Format:%i64d &%i64 U SubmitStatusPracticeHDU 4320
Description
Vance and Shackler like the playing games. One day, they is 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'll be Vance ' s win. Now given A and B, please help Vance to determine whether he'll win or not. Note that they is playing this game using a mystery language so, A and B May is 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'll 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
1#include <stdio.h>2#include <string.h>3#include <algorithm>4 using namespacestd;5 6 Long LonggcdLong LongALong Longb)7 { 8 if(a<b)9 returngcd (b,a);Ten Else if(b==0) One returnA; A Else - returnGCD (b,a%b); - } the - intMain () - { - intT,ca=1; + Long Longb; - intI,J,K,FLG; +scanf"%d",&T); A while(t--) at { -scanf"%i64d%i64d",&a,&B); - Long LongC=gcd (A, b), D; -a=a/c,b=b/C; -flg=1; - if(b>1) in { - while(1) to { + if(b==1) - Break; theD=gcd (b,c); * if(d==1) $ {Panax Notoginsengflg=0; - Break; the } +b=b/D; A } the } + if(a>1) - { $ while(1) $ { - if(a==1) - Break; theD=gcd (a,c); - if(d==1)Wuyi { theflg=0; - Break; Wu } -a=a/D; About } $ } - if(flg==1) -printf"Case #%d:yes\n", CA); - Else Aprintf"Case #%d:no\n", CA); +ca++; the } - return 0; $}View Code
#3 Arcane Numbers