数学 1

· · 个人记录

Miscellaneous

推论: a_1x_1 + a_2x_2 + \dots + a_nx_n = c iff gcd(a_1, a_2, \dots, a_n) | c

- Pell's Equation (?这是什么)

Example problems:

Watering an Array

好数

Ela's Fitness and the Luxury Number

Torn Lucky Ticket

USACO Bakery S

Matching Numbers

Martial Arts Tournament

Combinatorics

Example problems:

Remove 2 Letters

RELATIVNOST

Selling Paint (Derived problem from RELATIVNOST)

Graduation Trip

Number Theory and Modular Arithmetics

GCD and LCM

int gcd(int a, int b) {return !b? a: gcd(b, a%b);}

定义

GCD(a, b) = (a, b) LCM(a, b) = [a, b]

常见性质

  1. 对于任意整数m, (ma_1, ma_2, ..., ma_n) = m \times (a_1, a_2, ..., a_n)

    • 该性质同样适用于LCM
  2. 对于任意整数x, y: (a, b) = (a+bx, b) = (a, b+ay)

    • 不适用于LCM
  3. 结合律(a_1, a_2, ... a_{k+r}) = ((a_1, a_2, ..., a_k), (a_{k+1}, a_{k+2}, ..., a_{k+r}))

    • 该性质同样适用于LCM
  4. pq = (p, q) \times [p, q]
  5. 不算严格的数学性质?因为这里的\gcd默认是根据c++的实现定义的,也就是说如果某个参数为0, 他不会被考虑

    • \gcd(a_1, a_2, ..., a_n) = \gcd(a_2-a_1, a_3-a_2, a_4-a_3, ..., a_n-a_1, a_k)
    • 1 \leq k \leq n
    • 证明很简单:

      • lhs \geq rhs
      • g = \gcd(a_i)

      • g | a_{i+1} - a_i \forall \space 1\leq i < n, g|a_k
      • 所以g也是rhs的最大公约数。

        算数基本定理

Modular Arithmetics

Fermat's Little Theorem

a^p \equiv a \mod p \Rightarrow a^{p-1} \equiv 1 \mod p \Rightarrow a^{p-2 }\equiv \frac{1}{a} \mod p

Example problems

题单1

USACO Loan Repayment S