[Number theory] hdu 5974 A Simple Math Problem (number theory gcd)

 

Portal

• the meaning of problems

Has integer $ a, b $, there

$\left\{\begin{matrix}
x+y=a\\
LCM(x*y)=b
\end{matrix}\right.$

Seeking $ x, y $

• ideas

Solving Key: If $ gcd (p, q) = 1 $, the $ gcd (p + q, pq) = 1 $

Provided $ gcd (x, y) = g $, so $ p = \ frac {x} {g}, q = \ frac {y} {g} $, $ p, q $ coprime

则$\left\{\begin{matrix}
x+y=p*g+q*g=(p+q)g=a\\
LCM(x,y)=\frac{xy}{g}=p*q*g=b
\end{matrix}\right.$

Because $ p, q $ coprime, so $ gcd (a + b, ab) = gcd ((p + q) * g, pqg) = g $

Therefore, the $ gcd (x, y) = g = gcd (a + b, ab) $

 

 

 

 

Guess you like

Origin www.cnblogs.com/MMMinoz/p/11785359.html