↓快轉到主要內容

Gcd

Number Theory 數論
·4 分鐘
演算法 Math Number-Theory Prime Sieve Union-Find Gcd
GCD、判斷質數、埃氏篩 / 線性篩 / 最小質因數(SPF)、質因數分解後用 Union-Find 連起來,以及用質因數的最後出現位置切陣列
LeetCode 1071: Greatest Common Divisor of Strings
·1 分鐘
LeetCode Daily Easy String Gcd Math
LeetCode 解題紀錄
LeetCode 2709: Greatest Common Divisor Traversal
·2 分鐘
LeetCode Hard Math Number-Theory Union-Find Sieve Gcd Array
LeetCode 2709 解題筆記:任兩個 index 都能互通 ⇔ 全部在同一個連通塊;用 SPF 分解質因數,數字跟它的質因數在 Union-Find 裡合併;1 要特別處理
LeetCode 1979: Find Greatest Common Divisor of Array
·1 分鐘
LeetCode Easy Math Number-Theory Gcd Array
LeetCode 1979 解題筆記:找出最小值和最大值,用輾轉相除法算 GCD