关于lcm,gcd的一些性质

两个整数a,b  他们的最大公约数为n  最小公倍数为m  则有

  1. a,b都能分解为有限个素数的积               12 = 2^2 * 3^1 * 5^0 , 30 = 2^1 * 3^1 * 5^1
  2. n为a,b所有素因子取较小指数的积          n = 2^1 * 3^1 * 5^0 = 6
  3. m为a,b所有素因子取较大指数的积         m = 2^2 * 3^1 * 5^1 = 60
  4. n中只含a,b的全部公共素因子                 n = 2^1 * 3^1
  5. m中含有a,b的所有素因子                       m = 2^2 * 3^1 * 5^1
  6. m/n中只含a,b的全部指数不等素因子      m/n = 10 = 2^1 * 5^1
  7. m%n == 0                                            60 % 6 == 0
  8. m*n == a*b                                          60
    * 6 == 12 * 30
时间: 2024-08-24 21:43:56

关于lcm,gcd的一些性质的相关文章

LOJ 6229 LCM / GCD (杜教筛+Moebius)

链接: https://loj.ac/problem/6229 题意: \[F(n)=\sum_{i=1}^n\sum_{j=1}^i\frac{\mathrm{lcm}(i,j)}{\mathrm{gcd}(i,j)}\] 让你求 \(F(n) \bmod1000000007\). 题解: 设\(\begin{align} f(n)=\sum_{i=1}^n\frac{lcm(i,n)}{gcd(i,n)}&=\sum_{i=1}^n\frac{n*i}{(i,n)^2}\\ &=\su

树状数组区间更新区间查询以及gcd的logn性质

题目描述 给你一个长为n的序列a m次查询 每次查询一个区间的所有子区间的gcd的和mod1e9+7的结果 输入描述: 第一行两个数n,m之后一行n个数表示a之后m行每行两个数l,r表示查询的区间 输出描述: 对于每个询问,输出一行一个数表示答案 示例1 输入 5 7 30 60 20 20 20 1 1 1 5 2 4 3 4 3 5 2 5 2 3 输出 30 330 160 60 120 240 100 说明 [1,1]的子区间只有[1,1],其gcd为30[1,5]的子区间有:[1,1]

POJ 2429 GCD & LCM Inverse

设答案为ans1,ans2 ans1=a1*gcd,ans2=a2*gcd,a1,a2互质 gcd*a1*b1=lcm,gcd*a2*b2=lcm a1*b1=lcm=(ans1*ans2)/gcd=a1*a2 综上所诉,a1=b2,a2=b1. 也就是说,ans1=gcd*k1,ans2=gcd*k2 要求k1,k2尽量接近,并且k1,k2互质,并且,k2*k2=lcm/gcd 需要用到Pollard_rho分解质因数,然后暴力搜索寻找k1,k2.用了kuangbin大神的Pollard_rh

ACM数论之旅3---最大公约数gcd和最小公倍数lcm(苦海无边,回头是岸( ̄? ̄))

gcd(a, b),就是求a和b的最大公约数 lcm(a, b),就是求a和b的最小公倍数 然后有个公式 a*b = gcd * lcm     ( gcd就是gcd(a, b), ( •?∀•? ) 简写你懂吗) 解释(不想看就跳过){ 首先,求一个gcd,然后... a / gcd 和 b / gcd 这两个数互质了,也就是 gcd(   a / gcd ,b / gcd  )  =  1,然后... lcm = gcd *  (a / gcd) * (b / gcd) lcm = (a *

UVA - 11388 GCD LCM

II U C   ONLINE   C ON TEST   2 008 Problem D: GCD LCM Input: standard input Output: standard output 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

POJ 2429 GCD & LCM Inverse (大数分解)

GCD & LCM Inverse 题目:http://poj.org/problem?id=2429 题意: 给你两个数的gcd和lcm,[1, 2^63).求a,b.使得a+b最小. 思路: lcm = a * b / gcd 将lcm/gcd之后进行大数分解,形成a^x1 * b^x2 * c^x3-- 的形式,其中a,b,c为互不相同的质数.然后暴力枚举即可. 代码: #include<map> #include<set> #include<queue>

poj 2429 GCD &amp; LCM Inverse 【java】+【数学】

GCD & LCM Inverse Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9928   Accepted: 1843 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 a

最大公约数gcd和最小公倍数lcm

gcd(a, b),就是求a和b的最大公约数 lcm(a, b),就是求a和b的最小公倍数 然后有个公式 a*b = gcd * lcm     ( gcd就是gcd(a, b), ( •?∀•? ) 简写你懂吗) 解释(不想看就跳过){ 首先,求一个gcd,然后... a / gcd 和 b / gcd 这两个数互质了,也就是 gcd(   a / gcd ,b / gcd  )  =  1,然后... lcm = gcd *  (a / gcd) * (b / gcd) lcm = (a *

POJ 2429 GCD &amp; LCM Inverse(Pollard_Rho+dfs)

[题目链接] http://poj.org/problem?id=2429 [题目大意] 给出最大公约数和最小公倍数,满足要求的x和y,且x+y最小 [题解] 我们发现,(x/gcd)*(y/gcd)=lcm/gcd,并且x/gcd和y/gcd互质 那么我们先利用把所有的质数求出来Pollard_Rho,将相同的质数合并 现在的问题转变成把合并后的质数分为两堆,使得x+y最小 我们考虑不等式a+b>=2sqrt(ab),在a趋向于sqrt(ab)的时候a+b越小 所以我们通过搜索求出最逼近sqr