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 wha ...
分类:
其他好文 时间:
2019-02-09 12:00:20
阅读次数:
204
题意:给你一两个数m和n,它们分别是某对数A,B的gcd和lcm,让你求出一对使得A+B最小的A,B。 n/m的所有质因子中,一定有一部分是只在A中的,另一部分是只在B中的。 于是对n/m质因子分解后,dfs枚举在A中的质因子是哪些,在B中的是哪些,然后尝试更新答案即可。(因为相等的质因子只可能同时 ...
分类:
编程语言 时间:
2017-10-29 19:33:10
阅读次数:
155
GCD & LCM Inverse Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9756Accepted: 1819 Description Given two positive integers a and b, we ca ...
分类:
其他好文 时间:
2017-04-10 18:32:30
阅读次数:
161
用miller_rabin 和 pollard_rho对大数因式分解,再用dfs寻找答案即可。http://poj.org/problem?id=2429 1 #include 2 #include 3 #include 4 #include 5 using namespace s...
分类:
其他好文 时间:
2015-09-17 17:28:06
阅读次数:
187
GCD & LCM Inverse
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 9913
Accepted: 1841
Description
Given two positive integers a and b, we can easily calc...
分类:
其他好文 时间:
2014-11-15 15:37:41
阅读次数:
206
GCD & LCM Inverse
题目大意:给你两个数a和b的最大公约数和最小公倍数,求a和b
(其中在满足条件的情况下,使a+b尽量小)
思路:最大公约数和最小公倍数的规模为2^63,暴力果断不行。
已知a*b = L(最小公倍数)*G(最大公约数);
设p = L/a,q = L/b,s = L/G;
即p、q为a和b除去最大公约数的部分,且两者互质;
GCD(p,q) = 1,LCM(p,q) = p * q = L*L/(a*b) = L*L/(L*G) = L/G = s。
LCM(p,q) ...
分类:
其他好文 时间:
2014-10-15 18:14:21
阅读次数:
303
题意:给定gcd(a,b)和lcm(a,b) 求使得a+b最小的 a,b思路:结合算数基本定理中 gcd lcm的质因子表示形式把lcm(a,b)质因数分解 以后 通过dfs找到 a+b最小的a b即可#include #include#include#includeusing namespace ...
分类:
其他好文 时间:
2014-09-12 20:41:34
阅读次数:
225
1 //Accepted 164 KB 422 ms 2 //类似poj2429 大数分解 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespac...
分类:
其他好文 时间:
2014-08-29 21:14:08
阅读次数:
283
1 //Accepted 172 KB 172 ms 2 //该程序为随机性算法,运行时间不定 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 l...
分类:
其他好文 时间:
2014-08-28 23:56:36
阅读次数:
382