<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Number-Theory on</title><link>https://h30306.github.io/blog/zh-tw/tags/number-theory/</link><description>Recent content in Number-Theory on</description><generator>Hugo -- gohugo.io</generator><language>zh-tw</language><managingEditor>hwork0511@gmail.com (Wei Yi Chung)</managingEditor><webMaster>hwork0511@gmail.com (Wei Yi Chung)</webMaster><copyright>© 2026 Wei Yi Chung</copyright><lastBuildDate>Mon, 02 Nov 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://h30306.github.io/blog/zh-tw/tags/number-theory/index.xml" rel="self" type="application/rss+xml"/><item><title>LeetCode 4098: Minimize the Maximum Value of GCD-Connected Array</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-4098/</link><pubDate>Mon, 02 Nov 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-4098/</guid><description>LeetCode 4098 解題筆記：value 的最小質因數 p 決定一切：後一個最小是 value + p，之後都是偶數每次加 2；左邊可行的條件是 value - p &amp;gt;= 2 * index</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-4098/featured.png"/></item><item><title>Number Theory 數論</title><link>https://h30306.github.io/blog/zh-tw/algorithm/number-theory/</link><pubDate>Tue, 20 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/algorithm/number-theory/</guid><description>GCD、判斷質數、埃氏篩 / 線性篩 / 最小質因數（SPF）、質因數分解後用 Union-Find 連起來，以及用質因數的最後出現位置切陣列</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/algorithm/number-theory/featured.png"/></item><item><title>LeetCode 2584: Split the Array to Make Coprime Products</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2584/</link><pubDate>Tue, 13 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2584/</guid><description>LeetCode 2584 解題筆記：兩段乘積互質 ⇔ 沒有質因數同時出現在兩段；記下每個質因數最後出現的 index，從左往右擴張 reach，reach == i 時就能在 i 後面切</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2584/featured.png"/></item><item><title>LeetCode 4081: Prime Subset Selection II</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-4081/</link><pubDate>Tue, 13 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-4081/</guid><description>LeetCode 4081 解題筆記：篩出質數後做 0/1 背包，dp[j] 是湊出 j 的最少個數；質數由大到小放，個數一樣時新的組合開頭比較小，所以用 &amp;lt;= 更新就是字典序最小</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-4081/featured.png"/></item><item><title>LeetCode 1998: GCD Sort of an Array</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1998/</link><pubDate>Mon, 12 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1998/</guid><description>LeetCode 1998 解題筆記：同一個連通塊裡的數可以任意交換；用 SPF 把數字跟質因數合併，排序後每個位置的新舊數字在同一組就能排好</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1998/featured.png"/></item><item><title>LeetCode 2523: Closest Prime Numbers in Range</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2523/</link><pubDate>Mon, 12 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2523/</guid><description>LeetCode 2523 解題筆記：篩出範圍內的質數，相鄰的兩個質數才可能是最接近的；也可以從 left 往右試除，找到差是 2 的雙生質數就停</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2523/featured.png"/></item><item><title>LeetCode 2761: Prime Pairs With Target Sum</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2761/</link><pubDate>Mon, 12 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2761/</guid><description>LeetCode 2761 解題筆記：篩出 &amp;lt; n 的質數，x 從小到大、只看到 n / 2，x 和 n - x 都是質數就是一對</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2761/featured.png"/></item><item><title>LeetCode 1627: Graph Connectivity With Threshold</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1627/</link><pubDate>Sat, 05 Sep 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1627/</guid><description>LeetCode 1627 解題筆記：不用兩兩算 GCD；對每個 z &amp;gt; threshold，把 z 的所有倍數連起來，總共 O(n log n) 次合併</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1627/featured.png"/></item><item><title>LeetCode 3984: Divisible Game</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-3984/</link><pubDate>Mon, 06 Jul 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-3984/</guid><description>LeetCode 3984 解題筆記：k 是合數時，換成它的質因數只會更好（能整除的更多、k 更小），所以只要試每個數的質因數加上 2；每個候選 k 跑一次 Kadane</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-3984/featured.png"/></item><item><title>LeetCode 3918: Sum of Primes Between Number and Its Reverse</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-3918/</link><pubDate>Sun, 03 May 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-3918/</guid><description>LeetCode 3918 解題筆記：把 n 反轉，範圍是 [min, max]，逐一試除判斷質數加總；判斷整除要用 %，不要比較 // 和 /</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-3918/featured.png"/></item><item><title>LeetCode 2413: Smallest Even Multiple</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2413/</link><pubDate>Wed, 17 Dec 2025 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2413/</guid><description>LeetCode 2413 解題筆記：lcm(2, n)；n 是偶數就是 n，奇數就是 2n</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2413/featured.png"/></item><item><title>LeetCode 2709: Greatest Common Divisor Traversal</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2709/</link><pubDate>Thu, 07 Aug 2025 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2709/</guid><description>LeetCode 2709 解題筆記：任兩個 index 都能互通 ⇔ 全部在同一個連通塊；用 SPF 分解質因數，數字跟它的質因數在 Union-Find 裡合併；1 要特別處理</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2709/featured.png"/></item><item><title>LeetCode 3618: Split Array by Prime Indices</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-3618/</link><pubDate>Sat, 19 Jul 2025 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-3618/</guid><description>LeetCode 3618 解題筆記：判斷的是 index 是不是質數；用埃氏篩一次算出 0..n-1 哪些是質數，比每個 index 試除快</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-3618/featured.png"/></item><item><title>LeetCode 1979: Find Greatest Common Divisor of Array</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1979/</link><pubDate>Sat, 17 May 2025 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1979/</guid><description>LeetCode 1979 解題筆記：找出最小值和最大值，用輾轉相除法算 GCD</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1979/featured.png"/></item><item><title>LeetCode 952: Largest Component Size by Common Factor</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-952/</link><pubDate>Sat, 10 May 2025 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-952/</guid><description>LeetCode 952 解題筆記：有共同因數 ⇔ 有共同的質因數；把每個數分解質因數，同一個質因數的 index 用 Union-Find 合併，不用兩兩算 GCD</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-952/featured.png"/></item><item><title>LeetCode 204: Count Primes</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-204/</link><pubDate>Fri, 11 Nov 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-204/</guid><description>LeetCode 204 解題筆記：埃氏篩，只用質數 p 從 p² 開始把倍數劃掉，外層只要到 √n</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-204/featured.png"/></item><item><title>LeetCode 258: Add Digits</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-258/</link><pubDate>Mon, 22 Aug 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-258/</guid><description>LeetCode 258 解題筆記：反覆把位數相加直到剩一位；O(1) 解法是 digital root：1 + (n - 1) % 9</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-258/featured.png"/></item></channel></rss>