II |
|
Problem D: GCD LCM |
|
Input: standard input |
|
The GCD of two positive integers is the largest integer that divides both the integers without any remainder. The LCM of two positive integers is the smallest positive integer that is divisible by both the integers. A positive integer can be the GCD of many |
|
Input |
|
The first line of input will consist of a positive integer T. |
|
Output |
|
For each case of input, there will be one line of output. It will contain two positive integers |
|
Constraints |
|
- T ≤ 100 - Both G and L will be less than |
|
Sample Input |
Output for Sample Input |
2 1 2 3 4 |
1 2 -1 |
Problem setter: Shamim Hafiz 题意: 给你两个数的gcd和lcm,让你求时候是唯一的一对n,m,输出最小的一对 思路:设n = a*b*c*d, m = a*b*c*e, 那么gcd=a*b*c, lcm = a*b*c*d*e,那么假设不是唯一的话。那么lcm%gcd != 0,由于d和e的位置能够排列。要唯一的话,一定是lcm是gcd的倍数,且这对就是最小的
#include <iostream> |
相关文章
- 11-22(UVA - 10791)Minimum Sum LCM (唯一分解定理)
- 11-22gcd最大公约数 && lcm最小公倍数
- 11-22hdu GCD and LCM
- 11-22【UVA12716】 GCD等于XOR
- 11-22UVA11417 GCD
- 11-22UVA 11426 GCD Extrme (Ⅲ)
- 11-22GCD与LCM
- 11-22gcd和lcm
- 11-22POJ2429--GCD & LCM Inverse (UNSOLVED)
- 11-22[HDU 5382] GCD?LCM!