SDU summer training qualifying (4)
C. Pick Your Team
Meaning of the questions have \ (n \) individuals, each person has the ability to value, A and B, who in turn elect, A before the election, according to one B selection given priority,
A can pick. A want to maximize the value of one's own ability.
practice
- Division scheme legitimate Sufficient Conditions: any prefix, \ (the selected human B - A selected person> -1 \)
- Consider the DP, \ (DP [I] [J] \) represents Before considering \ (I \) individual, \ (J \) individuals were selected B, A and B, the maximum points difference.
- Consider transfer, enumerate \ (i + 1 \) personal ownership can be.
F. It's a Mod, Mod, Mod, Mod World
The meaning of problems seeking \ (\ sum_ {i = 1 } ^ {n} [pi \% q] \)
practice
- GCD classic application.
- \(\sum_{i=1}^{n}[pi\%q] = \sum_{i=1}^{n} (pi-[\frac{pi}{q}]q)=(\sum_{i=1}^{n}pi)-q(\sum_{i=1}^{n}[\frac{pi}{q}])\)
- Only needs \ (f (n, p, q) = \ sum_ {i = 1} ^ {n} [\ frac {pi} {q}] \)
- If \ (p \ geq q \) recursively to \ (f (n, p \ % q, q) \)
- If \ (p <q \) may be enumerated \ (X \) , Statistics \ ([\ frac {pi} {q}] \ geq x \) a \ (I \) number of programs can exchange \ (P , q \)
- More details see Golden Bin "application Euclidean algorithm" In 2009 dissertation
K. Subsequences in Substrings
Practice sequence automatic machine, pre-position \ (x \) next character \ (ch \) where, enumerated starting point, then jumped back. Complexity \ (O (| S | * | T |) \)