[原创]POJ 2429 GCD&LCM Inverse [pollard_rho]【数论】
[原创]POJ 2429 GCD&LCM Inverse [pollard_rho]【数论】
2016-09-21 18:29:01 Tabris_ 阅读数:237
博客爬取于2020-06-14 22:43:13
以下为正文
版权声明:本文为Tabris原创文章,未经博主允许不得私自转载。
https://blog.csdn.net/qq_33184171/article/details/52611426
题目链接:http://poj.org/problem?id=2429
-----------------------------.
GCD & LCM Inverse
Time Limit: 2000MS Memory Limit: 65536K
Total Submissions: 13908 Accepted: 2572
Description
Given two positive integers a and b, we can easily calculate the greatest common divisor (GCD) and the least common multiple (LCM) of a and b. But what about the inverse? That is: given GCD and LCM, finding a and b.
Input
The input contains multiple test cases, each of which contains two positive integers, the GCD and the LCM. You can assume that these two numbers are both less than 2^63.
Output
For each test case, output a and b in ascending order. If there are multiple solutions, output the pair with smallest a + b.
Sample Input
3 60
Sample Output
12 15
---------------------------------------------.
题目大意:
就是给你两个数的GCD和LCM值 让你求出和最小的这两个数
解题思路:
lcm=a/gcdb;
lcm/gcd=a/gcdb/gcd;
然后把lcm/gcd 这个结果质因子分解一下就行了
然后DFS求解和最小的值…
附本题代码
--------------------------------.
1 | /*******************Miller_Rabin素数测试&&Pollard_rho整数分解**************************/ |