All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Vietnamese as well.
It is well-known that ∑sqrt(ai), ai ∈ N is a root of some integer-coefficient polynomial. For example: sqrt(2) is a root of polynomial: x2 − 2. Now, your task is to find not only such polynomial but also the minimal one. When comparing two polynomials, firstly, we consider their degree and then the coefficient of the highest term, and then the second highest term and so on.(Note that we consider only polynomial with the coefficient of highest term is positive)
First line contains an integer T denotes the number of testcases. Each testcase is described by an integer n and followed by n space-seperated integers ai.
Each testcase print an integer k denotes the degree of polynomial in a single line. Then next line print k + 1 space-seperated integers modolo 109 + 7, coefficients from lowest to highest term.
1 ≤ T ≤ 5, 1 ≤ n ≤ 15
ai are n distinct primes, 1 ≤ ai ≤ 109
- Subtask #1: (10 points): n ≤ 3
- Subtask #2: (20 points): n ≤ 5
- Subtask #3: (30 points): n ≤ 10
- Subtask #4: (40 points): n ≤ 15
2 1 2 2 2 3Output:
2 1000000005 0 1 4 1 0 999999997 0 1
The first polynomial is x2 − 2, and the second one is x4 − 10x2 + 1.
|Tags||chemthan, fft, hard, july17, math, ntt|
|Time Limit:||4 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.