随笔分类 - 数论
摘要:说明:本文用 \(\phi\) 表示欧拉函数而不用 \(\varphi\),尽管后者更为常用。\(\DeclareMathOperator{\lcm}{lcm}\) 欧拉函数 \(\phi\colon\mathbb Z_{>0}\to \mathbb Z\) 定义为 \[ \phi(n) = |\{
阅读全文
摘要:此题是 2018 年 ICPC Asia Beijing Regional Contest 的 C 题。 题目大意 求斜边长度不超过 $n$($ n \le 10^9$) 的勾股数的数量。不计两直角边的顺序,即勾股数 $(a, b, c)$ 和 $(b, a, c)$ 视作同一组。 分析 这是一道颇
阅读全文
摘要:本文是一篇长文,尚未完成。 引子 一 算法竞赛中常见一类计数问题: 函数 \(g : \mathbb Z\_{\ge 1} \to \mathbb Z\_{\ge 0}\) 已知。函数 \(f : \mathbb Z_{\ge 1} \to \mathbb Z_{\ge 0}\), $f(n) :=
阅读全文
摘要:在集合 $[n]$ 上使用容斥原理。 固定 $i$,考虑有多少个 $j \in [n]$ 满足 $\gcd(i, j) = \gcd(a_i, a_j) = 1$,将此数目记作 $f_i$。暂时不考虑条件 $ i \le j $ 。 考虑 $[n]$ 的某些子集。$S_{x,y} := \\{ i\
阅读全文
摘要:设在第 $x$ 天二人都 lucky,则有 $\DeclareMathOperator{\lcm}{lcm}$ $ x = y_a t_a + R_a $ $ x= y_b t_ b + R_b$ 约束条件: $ l_a \le R_a \le r_a$,$l_b \le R_b \le r_b$
阅读全文
摘要:For non negative integers $m$ and $n$ and a prime $p$, the following congruence relation holds: $$\binom{m}{n} \equiv \prod_{i=0}^{k} \binom {m_i}{n_i
阅读全文
摘要:题目大意 $n$($1\le n\le 2000$)个正整数 $a_1, a_2, \dots, a_n$($a_i\le 5\times 10^7$)分布在一个圆环上。 定义 $b_k$ 为:将环上的数划分成 $k$ 段,每段上的数之和的 GCD 的最大值。 求 $b_1, b_2, \dots,
阅读全文
摘要:题目大意 给定 $n$($1\le n\le 1000$)个正整数 $a_1, a_2, \dots, a_n$($a_i \le 10^{12}$),令 $s$ 为这 $n$ 个数之和。求 $$ \frac{s! } {\prod\limits_{1\le i\le n} a_i !} \bmod
阅读全文
摘要:费马测试(Fermat test) Some of the cryptographic algorithms make use of big prime numbers. However, checking if a big number is prime is not so easy. Howev
阅读全文
摘要:Problem 求 $[1 \dots N]$中素因子数最多且最小的数 $n$,$N$ 充分大。 Solution 将任意自然数 $n$ ($n>2$) 分解 $$ n = p_1^{k_1 } p_2^{k_2} p_3^{k_3} \dots P_m^{k_m} \quad (p_1<p_2<
阅读全文
摘要:"传送门" time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder has recently found an
阅读全文
摘要:分数的和取模 考虑两个分数 $\frac ab, \frac cd$($a,b, c, d\in \mathbb{Z}$,$b,d 0$),正整数 $m$ 和 $b, d$ 都互质。若正整数 $x$ 与 $m$ 互质,用 $x^{ 1}$ 表示 $x$ 在模 $m$ 下的逆元。则有 $ab^{ 1}
阅读全文
摘要:传送门 GCD Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem DescriptionGive you a sequence of $N(N≤100,000)$ int
阅读全文
摘要:问题 求 $[L, R]$ 之间的素数表。 解法 一个合数 $n$ 的最小素因子不超过 $\sqrt{n}$。因此,在埃氏筛法的过程中,每当“新发现”一个素数 $p$,可以从 $p^2$ 筛起,而不必从 $2p$ 筛起。 先用埃氏筛法求出 $[1,\lfloor \sqrt{R} \rfloor]$
阅读全文

浙公网安备 33010602011771号