0w1

Entries from 2017-03-11 to 1 day

HR Hyperrectangle GCD ( Mobius Inversion )

https://www.hackerrank.com/challenges/hyperrectangle-gcd題意: 有 K 個箱子,裡面分別有 [ 1, N[ i ] ] 的數字。現在要從每個箱子里抽一個數字,求其最大公因數。問所有取法可以產生的最大公因數總和。資料規模: Constraints 1 2 1 p.s. T * nk * K 明…

Codechef COPRIME3 ( Mobius Inversion )

https://www.codechef.com/problems/COPRIME3可以先看這個連結了解 Mobius Inversion 是什麼: A Dance with Mobius Function - Posts - Quora題意: 給 N 個數字的數列 A,問有多少對 ( i, j, k ) 滿足 i 資料規模: N ≤ 1e5 1 ≤ A[ i ] ≤ 1e6解法: 和上方…

CFR 220 B. Little Elephant and Array ( Mo's Algorithm )

Problem - B - Codeforces題意: 給 N 個元素的序列,M 筆詢問,問考慮 A[ L, R ] 有多少不同的數字 A[ x ] 出現恰好 A[ x ] 次。資料規模: The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 1e5) — the size of array a and the…