rev='made'/> name='keywords'/> name='author'/> ANURANAN: UVa Solution 11388: gcd-lcm

Welcome Note

Hi,
I'm Anisuzzaman Babla . I am a full stack Android Application Developer. I am working with Android for more than two years. I have completed my graduation from IIT, Jahangirnagar University. I have developed a series of commercially successful apps on Android. Moreover, 10+ of my Apps are live at Google play store. .
Thank You

UVa Solution 11388: gcd-lcm

#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    long long G,L,a,b;
    int nCases;
    scanf("%d",&nCases);
    while(nCases-->0)
    {
        a=b=1;
        scanf("%lld %lld",&G,&L);

            int factor;
            factor=1;
            bool check;
            check=true;
            while(check&&a<=L)
            {
                a=G*factor;
                factor++;
                b=(G*L)/a;
                if(b%G==0&&L%b==0)
                    check=false;
            }
            if(!check)
            printf("%lld %lld\n",a,b);
            else printf("-1\n");

    }
    return 0;
}