Problem Ideas & Solution
Tuesday, October 29, 2019
UVA - 11388 - GCD LCM
Code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int q;
cin>>q;
while(q--)
{
long long g,l;
cin>>g>>l;
if(l<g)
swap(g,l);
if(l%g==0)
cout<<g<<" "<<l<<endl;
else
cout<<"-1"<<endl;
}
return 0;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment