UVA 11388

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d=0,e=0;
    cin>>a;
    for(int i=0; i<a; i++)
    {
        cin>>b>>c;
        d=__gcd(b,c);
        e=(b*c)/d;
        if(c%b==0)
        {
            cout<<d<<" "<<e<<endl;
        }
        else
        {
            cout<<"-1"<<endl;
        }
        d=0;
        e=0;
    }
    return 0;
}

Comments

Popular posts from this blog

C++ STL practice problem link

Binary Index Tree(BIT)

Combinatorics