Sign in $ create-account
~/problems ~/discussion ~/contests ~/submission
← ~/problems
P2002

GCD and LCM

Easy
// Description
Given two positive integers a and b, output their greatest common divisor and least common multiple.
// Input
A single line with two integers a and b (1 <= a, b <= 10^9).
// Output
Two integers on one line: gcd(a, b) and lcm(a, b), separated by a space.
// Hint
lcm(a, b) = a / gcd(a, b) * b. Divide before multiplying to avoid overflow.
// Samples
Sample Input
12 18
Sample Output
6 36
// Problem Info
DifficultyEasy
Acceptance40%
Time Limit1000 ms
Memory Limit65536 KB
Accepted4
MathNumber Theory
// Discussion

No Discussion