Provincial election simulation 1

Sky debris

  First, observe that the problem of strange conditions $ n, m <= p * (p-1) $, can be found for a number of x, determined $ x \% p $, $ x \% (p-1) $ , referred to as $ (i, j) $ then every $ (i, j) $ corresponds to a specific $ x $.

  Thus, we can enumerate the $ (i, j) $, then if there is a quad $ x ^ {y} \ equiv n ^ {m} mod p $, we can find unique necessarily point $ (I, J) $, satisfying $ i% p = x, i% (p-1) = m, j% p = n, j% (p-1) = y $, and therefore, as long as each set $ i ^ { j} \ mod \ p $ thrown into the bucket, count I $ I $ is the number of points is $ c (i) $, then the answer is: $ \ sum \ limits_ {i = 0} {p-1} c (i) ^ 2 $.

  Consider how to quickly find the number of elements in each bucket. Multiplication modulo not consider processing, difficult to think of the root can be used to replace the original, the original condition $ x ^ {y} \ equiv n ^ {m} mod p $ becomes a $ g ^ {xy} \ equiv g ^ {nm} $, can be converted to find $ 0 <= a, b, c, d <quad p-1 $, so $ a * b \ equiv n * m $, attention ignored here $ x = 0 $ or $ n = 0 $ case (not represented ^ {x} $ by $ g), can be $ (p-1) ^ 2 $ calculated.

  Think of the examination room where he died. Provided $ cnt (n) $ represents a number satisfying $ 0 <= four yuan number of groups a, b, c, d <n $, so $ n-= \ after prod pi ^ ci $ can $ CRT $ obtained: $ cnt ( n) = \ prod cnt (p_ {i} ^ {c_ {i}}) $

  So if you ask them a $ cnt (p ^ k) $. Provided $ c (i) $ $ I $ denotes the number of elements in the tub, so $ i = p ^ {c} * s $ then there is:

  $ C (i) = (c + 1) * p ^ {k-1} * (p-1), c (0) = (k + 1) * (p-1) * p ^ {e-1} $, $ enumerator is substantially contained in the number of p $ (a, b), calculate the respective contributions.

  So we find the number of elements in the barrel with only about $ c $, so the direct enumeration of $ c $ can be calculated. The final answer is $ cnt (p-1) $;

Future Puzzle

  If the original sequence of $ p $ as a polynomial in question to the array $ A $ is $ p $ circular convolution. A direct point DFT transformed with an expression value, then the value of the square root and point IDFT can get back the original polynomial.

  But the complex evolution will get two values, so you can get is an enumeration of violence which one can examine violence.

  $O(T*2^{\frac{2}{n}}*n^2)$

Perfect theory

  Found to do so directly with the proviso that at the same time pick two points, you must choose some point, however, it does not deal with the situation at the same time pick two points, and then he died.

  However, we can enumerate a root Unicom block, then select a point must choose his father, restrictions on only one point, and the right to direct the largest sub-graph can be closed.

Guess you like

Origin www.cnblogs.com/hzoi-cbx/p/12057044.html