<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>数学 on 万束屋</title><link>https://huayuliu114514.github.io/categories/%E6%95%B0%E5%AD%A6/</link><description>Recent content in 数学 on 万束屋</description><generator>Hugo</generator><language>zh-cn</language><lastBuildDate>Tue, 01 Dec 2026 15:34:00 +0800</lastBuildDate><atom:link href="https://huayuliu114514.github.io/categories/%E6%95%B0%E5%AD%A6/index.xml" rel="self" type="application/rss+xml"/><item><title>关于整除的题目</title><link>https://huayuliu114514.github.io/posts/2026-12-01-1534-%E6%95%B0%E8%AE%BA%E5%B0%8F%E7%9F%A5%E8%AF%86/</link><pubDate>Tue, 01 Dec 2026 15:34:00 +0800</pubDate><guid>https://huayuliu114514.github.io/posts/2026-12-01-1534-%E6%95%B0%E8%AE%BA%E5%B0%8F%E7%9F%A5%E8%AF%86/</guid><description>&lt;p&gt;每日一题做多了也接触到了很多gcd，lcm和整除相关的题目，这里也放一下总结吧（回头汇总，大概有时间会的吧）
C++17更新了很多相关的库：可以直接调用gcd(int,int)&amp;amp;lcm(int,int)计算
介绍手动计算gcd和lcm的算法：
1、gcd（辗转相除法）：
gcd(a, b) = gcd(b, a % b)，直到 b == 0，此时 a 就是 gcd
（补充：更相减损术）gcd(a,b) = gcd(a-b, b)（假设 a &amp;gt; b），直到两数相等
2、lcm（依托gcd）：
long long lcm(long long a, long long b) {
return a / gcd(a, b) * b; // 先除后乘，防溢出
}
数论小知识： [1, x] 中能被 a 整除的数的个数 = ⌊x/a⌋
例题：
&lt;a href="https://leetcode.cn/problems/ugly-number-iii/description/?envType=daily-question&amp;amp;envId=2026-12-01"&gt;https://leetcode.cn/problems/ugly-number-iii/description/?envType=daily-question&amp;amp;envId=2026-12-01&lt;/a&gt;
&lt;a href="https://leetcode.cn/problems/nth-magical-number/description/"&gt;https://leetcode.cn/problems/nth-magical-number/description/&lt;/a&gt;&lt;/p&gt;</description></item></channel></rss>