HDU 4569 Special equations(取模)

Posted zhaop

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HDU 4569 Special equations(取模)相关的知识,希望对你有一定的参考价值。

Special equations
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Description

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

Input

  The first line is the number of equations T, T<=50. 
  Then comes T lines, each line starts with an integer deg (1<=deg<=4), meaning that f(x)‘s degree is deg. Then follows deg integers, representing a n to a 0 (0 < abs(a n) <= 100; abs(a i) <= 10000 when deg >= 3, otherwise 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 are many x fitting the equation, else output "No solution!"
 

Sample Input

4
2 1 1 -5 7
1 5 -2995 9929
2 1 -96255532 8930 9811
4 14 5458 7754 4946 -2210 9601
 

Sample Output

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

以上是关于HDU 4569 Special equations(取模)的主要内容,如果未能解决你的问题,请参考以下文章

hdu 1496 Equations

hdu 5937 -- Equation(搜索)

HDU 1840 Equations (简单数学 + 水题)(Java版)

HDU 2199 Can you solve this equation?(二分搜索)

HDU 5937 Equation

HDU 2199 Can you solve this equation?(二分精度)