11388 - GCD LCM

All about problems in Volume 113. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

arifcsecu
Learning poster
Posts: 64
Joined: Fri Sep 25, 2009 11:29 am
Location: Chittagong,University of chittagong
Contact:

Re: 11388 - GCD LCM

Post by arifcsecu » 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
Try to catch fish rather than asking for some fishes.

User avatar
plamplam
Experienced poster
Posts: 150
Joined: Fri May 06, 2011 11:37 am

Re: 11388 - GCD LCM

Post by plamplam » Fri Jul 01, 2011 8:23 pm

Nice problem lol....sometimes simple problems require deep thinking :wink: :wink:
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson

raj
Learning poster
Posts: 78
Joined: Fri Feb 15, 2013 5:39 pm

Re: 11388 - GCD LCM

Post by raj » 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?? :(

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11388 - GCD LCM

Post by brianfry713 » Wed Mar 20, 2013 10:29 pm

if L%G!=0
print -1
else
print a=G and b=L
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 113 (11300-11399)”