eolymp
bolt
Try our new interface for solving problems
Problems

RSA Factorization

RSA Factorization

The positive integer \textbf{n} is given. It is known that \textbf{n = p * q}, where \textbf{p} and \textbf{q} are primes, \textbf{p} <= \textbf{q} and |\textbf{q-kp}|<=\textbf{10^5} for some given positive integer \textbf{k}. You must find \textbf{p} and \textbf{q}. \InputFile Each line contains integers \textbf{n} (\textbf{1} < \textbf{n} < \textbf{10^120}) and \textbf{k} (\textbf{0} < \textbf{k} < \textbf{10^8}). \OutputFile For each pair of numbers \textbf{n} and \textbf{k} print in separate line the product \textbf{p * q} such that \textbf{p} <= \textbf{q} .
Time limit 2 seconds
Memory limit 64 MiB
Input example #1
35 1
121 1
1000730021 9
Output example #1
5 * 7
11 * 11
10007 * 100003
Source 2009 South Eastern European Regional Programming Contest, October 17, Problem A