From c2794dbd9816161c984329f36d879fe8c746bd35 Mon Sep 17 00:00:00 2001 From: xingyou wu <3050128610@qq.com> Date: Tue, 8 Apr 2025 09:22:21 +0800 Subject: [PATCH] =?UTF-8?q?lanqiao=2019711=20=E5=AE=9D=E7=9F=B3=E7=BB=84?= =?UTF-8?q?=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 15lanqiao/test5.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/15lanqiao/test5.cpp b/15lanqiao/test5.cpp index aba1db4..c962995 100644 --- a/15lanqiao/test5.cpp +++ b/15lanqiao/test5.cpp @@ -1,10 +1,20 @@ // lanqiao 19711 宝石组合 #include using namespace std; +/* +解析: +唯一分解定理: +任何一个大于1的自然数N,如果N不是质数,那么N可以唯一分解成有限个质数的乘积 +N1=p1^a1*p2^a2*...*pn^an +N2=p1^b1*p2^b2*...*pn^bn +则gcd(N1, N2)=p1^min(a1, b1)*p2^min(a2, b2)*... *pn^min(an, bn) +则lcm(N1, N2)=p1^max(a1, b1)*p2^max(a2, b2)*...*pn^max(an, bn) +假设Ha,Hb,Hc相同质因子的幂次分别为x,y,z则题目中的表达式等价于 +x+y+z+max(x,y,z)-max(x,y)-max(x,z)-max(y,z) +*/ const int N = 1e5 + 10; int a[N]; vector fac[N], s[N]; - int main() { for(int i = 1; i <= 1e5; i++){ for(int j = i; j <= 1e5; j += i){