版本比较
数论专题(莫反)题单&题解
正文
增加 8 行删除 8 行
123 行未改动全部展开124125126127128128129130131132152 行未改动全部展开28528628728828928929029129229343 行未改动337338339340341341342343344345282 行未改动全部展开628629630631632632633634635636123 行未改动全部展开7607617627637647647657667677684 行未改动773774775776777777778779780781782783784785786787787788789790791791792793794795288 行未改动全部展开123 行未改动全部展开能量汇集机器在汇集的过程中有一定的能量损失。如果一棵植物与能量汇集机器连接而成的线段上有 $k$ 棵植物,则能量的损失为 $2k + 1$。例如,当能量汇集机器收集坐标为 $(2, 4)$ 的植物时,由于连接线段上存在一棵植物 $(1, 2)$,会产生 $3$ 的能量损失。注意,如果一棵植物与能量汇集机器连接的线段上没有植物,则能量损失为 $1$。现在要计算总的能量损失。
下面给出了一个能量采集的例子,其中 $n = 5$,$m = 4$,一共有 $20$ 棵植物,在每棵植物上标明了能量汇集机器收集它的能量时产生的能量损失。
 
在这个例子中,总共产生了 $36$ 的能量损失。
152 行未改动全部展开int main() { init(50000); int T; T = read(); while (T--) { static int a, b; a = read(), b = read(), k = read(); static int a, b; a = read(), b = read(), k = read(); printf("%lld\n", f(a, b)); } return 0;}43 行未改动int main() { init(50000); int T; T = read(); while (T--) { static int a, b, c, d; a = read(), b = read(), c = read(), d = read(), k = read(); static int a, b, c, d; a = read(), b = read(), c = read(), d = read(), k = read(); printf("%lld\n", f(b, d) - f(b, c - 1) - f(a - 1, d) + f(a - 1, c - 1)); } return 0;}282 行未改动全部展开# T8 [P3327 【SDOI2015】约数个数和](https://www.luogu.com.cn/problem/P3327)
## 题目描述
设 $d(x)$ 为 $x$ 的约数个数,给定 $n,m$,求 设 $d(x)$ 为 $x$ 的约数个数,给定 $n,m$,求$$\sum_{i=1}^n\sum_{j=1}^md(ij)$$
123 行未改动全部展开下面**分类讨论**两种情况:
### 1. $T \in Prime$
$\because d^k \mu(\frac{T}{d}) = $\because d^k \mu(\frac{T}{d}) =\left\{\begin{aligned}-1 & & (d=1) \\T^k & & (d=k) \\4 行未改动$\therefore g(T) = T^k - 1$
### 2. $T | p^x, x \gt 1, p \in Prime$
$\because d^k \mu(\frac{T^x}{d}) = $\because d^k \mu(\frac{T^x}{d}) =\left \{\begin{aligned}-(T^{x-1})^k & & (d=T^{k-1}) \\(T^x)^k & & (d=T^k) \\\end{aligned}\right.$
$$\therefore g_{i \times prime_j} = \therefore g_{i \times prime_j} =\left\{\begin{aligned}g_i \times g_{prime_j} & & (\gcd(i, prime_j) == 1) \\g_i \times prime_j^k & & (prime_j | i) g_i \times prime_j^k & & (prime_j | i)\end{aligned}\right.$$
288 行未改动全部展开