NOIP 2014 Solution equation

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.