Page 2 of 2

### Re: 11388 - GCD LCM

Posted: Thu Oct 01, 2009 11:06 am
Another One of the easiest problem like Hasmot the brave warrior:

we know that
a x b= gcd(a,b) x lcm(a,b)
or gcd(a,b) x lcm(a,b)= a x b ....................(1)

Input is :
gcd(a,b) and lcm(a,b)

output :
a=?
b=?
from equation (i)
there is symmetry

try:
from forward:
a=12
b=18

gcd(12,18)=6
lcm(12,18)=36

12 x 18 = 6 x 36

from reverse:
a=6
b=36
gcd(6,36)= 6
lcm(6,36)= 36

6 x 36 = 6 x 36

ha ha ha ............
just :
input = output if b is divisible by a
otherwise
print -1

### Re: 11388 - GCD LCM

Posted: Fri Jul 01, 2011 8:23 pm
Nice problem lol....sometimes simple problems require deep thinking

### Re: 11388 - GCD LCM

Posted: Tue Mar 19, 2013 3:03 am
Can anyone please explain me how can i know that a is minimized or not...

""output the pair for which a is minimized. In case there is no such pair, output -1.""

what does this sentence means??

### Re: 11388 - GCD LCM

Posted: Wed Mar 20, 2013 10:29 pm
if L%G!=0
print -1
else
print a=G and b=L