Cubelover
Time limit1sMemory limit128 MB
Given a sequence, decide whether real coefficients a, b, c, d exist so that x_i equals a*i^3 + b*i^2 + c*i + d for every position i.
- Level
Medium4 of 10
- Topics
- Math, Implementation, Brute force
- Solved
- No attempts yet
Problem
Jihak is a well-known cubelover: he loves cubic polynomials.
One sunny spring day, Jihak spotted Seunghyun playing with an integer sequence of length at the apartment-complex playground. Jihak was the boss of that apartment complex, and he was Seunghyun's elder brother in spirit, born a full 45 days before him. The moment Jihak saw Seunghyun, he snatched the sequence away.
Seunghyun broke down crying on the spot. His heart softening, Jihak promised to return the sequence if Seunghyun could find real numbers , , , such that
holds for every integer with . (Strictly speaking a cubic polynomial requires , but Jihak does not seem to want to be that strict, so is allowed as well.)
Out enjoying a rare day away from school, you met eyes with the sobbing Seunghyun. He ran straight up to you and begged you to find such real numbers , , , as quickly as possible. Can you wipe away Seunghyun's tears?
Input
The input contains several test cases. The first line contains the number of test cases ().
Each of the next lines describes one test case. It begins with an integer (), the length of the sequence, followed by integers; the -th of them is ().
Output
For each test case, print YES if real numbers , , , satisfying exist, and NO otherwise. Print one answer per line.
Hint
In the first test case, one possible answer is , , , .