F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Common Roots

Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others)
Total Submission(s): 369    Accepted Submission(s): 154


Problem Description
We have many polynomials modulo p (p is a prime number). An interesting issue would be to determine whether they have some roots in common. Notice roots we mention here are integers in modulo p system (0 <= root < p). Moreover, if the given polynomial is of order r, we will guarantee that it has r roots.
For example, we have
x^2 + 13x + 36 (mod 37)
x^3 + 14x^2 + 49x + 36 (mod 37)
If x = 33 or x = 28, both of them would give the value of 0. So 33 and 28 are the roots in common.
 

Input
There are many test cases (less than1000).
In each case, the integer in the first line is n (the number of polynomials in this case). Then n lines followed. Each of them starts with an integer r (order of polynomials, r <= 50), and r + 1 integers (a(r), a(r-1) ,..., a(0)), which means the polynomial goes like:
a(r) * x^r + a(r-1) * x^(r-1) + ˇ­ +a(1) * x + a(0) (mod 999983).
To make it easier, p is set to be 999983, as you see.
 

Output
For each case, just output ˇ°YESˇ± if they have common roots, otherwise ˇ°NOˇ± in a single line.
 

Sample Input
2 2 1 13 36 3 1 14 49 36
 

Sample Output
YES
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 15:35:18, Gzip enabled