HDU 4569 Special equations (modulo)

Source: Internet
Author: User

Special equationsTime limit:1000MS Memory Limit:32768KB 64bit IO Format:%i64d &%i64 U SubmitStatusPracticeHDU 4569

Description

Let f (x) = a nx n +...+ a 1x +a 0, in which a I (0 <= i <= N) is all known integers. We call F (x) 0 (mod m) congruence equation. If M is a composite, we can factor m to powers of primes and solve every such single equation after which we merge them Using the Chinese Reminder theorem. In this problem, you is asked to solve a much simpler version of the such equations, with the m to be prime ' square.

Input

The first line is the number of equations T, t<=50.
Then comes T-lines, each line starts with a integer deg (1<=deg<=4), meaning that f (x) ' s degree are deg. Then follows deg integers, representing a n to a 0 (0 < ABS (A-N) <=, ABS (a i) <= 10000 when deg >= 3, othe Rwise ABS (a i) <= 100000000, i<n). The last integer is Prime pri (pri<=10000).
Remember, your task is to solve F (x) 0 (mod pri*pri)

Output

For each equation f (x) 0 (mod pri*pri), first output the case number, then output anyone of X if there is many X fitting The equation, else output "No solution!"

Sample Input

42 1 1-5 71 5-2995 99292 1-96255532 8930 98114 14 5458 7754 4946-2210 9601

Sample Output

Case #1: No solution! Case #2:599Case #3:96255626Case #4: No solution!

HDU 4569 Special equations (modulo)

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.