HDOJ2504

#include <iostream>
using namespace std;

bool Judge(int a,int
 b)
{
    
int
 tt,r;
    
if(a < b){tt = a; a = b; b = tt;}

    r 
= a % b;
    
while
(r)
    
{
        a 
=
 b;
        b 
=
 r;
        r 
= a %
 b;
    }

    
if(b != 1)return false;
    
else return true
;
}


int main()
{
    
int
 a,b,i;
    
int
 n;
    
while(cin>>
n)
        
while(n-- && cin>>a>>
b)
        
{
            a 
/=
 b;
            
for(i = 2;; i ++
)
            
{
                
if(a % i != 0 &&
 Judge(a,i))
                
{//因b为a和c的最大公倍数,此时a和c应当是无公倍数
                    cout<<* b<<endl;
                    
break
;
                }

            }


        }

    
return 0;
}

posted on 2009-03-11 20:27  Xredman  阅读(221)  评论(0编辑  收藏  举报

导航