Today re-Noip the original problem, then nothing, directly output 0, made 10 points, today to see the dead also 30, 50, with a hash of the online method barely get 70 points, AC has not yet read, the following to a standard of the puzzle bar, to strive for an early understanding.
30%: Poor lift X, determine whether the equation is true.
50%: Adding high-precision multiplication, addition in the 30% practice. The reason for not being highly refined is that as long as you move the item with the same symbol to the side of the equation, the values on both sides of the equation are calculated as equal. Also remember to write Qin Jiushao (Horner's rule) optimization.
70%: According to the nature of the same remainder, the same symbol can support the same plus a number, the same multiply one number. Then the equivalent of both sides of a number at the same time, if the same symbol is established, then the original equation may be established, the other is to sift out the X. In the actual operation of the AI with a prime number modulo, and then the poor X, while taking the MoD side operation. You can then reduce the complexity of the single test to O (n)
Complexity: O (NM)
100%: According to the two-term theorem, F (x+p) After expansion must be organized into F (x) +t, where T is a polynomial about p, and in the context of congruence (mod p), T is negligible, that is, then the fact that f (x) mod p is a periodic function on [1,m], So all we have to do is preprocess F (0) ~f (p-1), which is equivalent to knowing the full extent of the F (X) mod p in that interval. So we optimize the above algorithm, from selecting a prime number to select multiple small prime numbers pi for verification, after each pi 0~ (pi-1) preprocessing, you can sift out some x. Finally output the remaining x.
Complexity: O (+M)
NOIP 2014 Solution equation