Submit | All submissions | Best solutions | Back to list |
POLYNOM - Polynomial |
The number of spectators at the FIFA World Cup increases year after year. As you sell the advertisement slots during the games for the coming years, you need to come up with the price a company has to pay in order to get an advertisement slot. For this, you need a good estimate for the number of spectators in the coming games, based on the number of spectators in the past games.
Your intuition tells you that maybe the number of spectators could be modeled precisely by a polynomial of degree at most 3. The task is to check if this intuition is true.
Input
The input starts with a positive integer N, the number of test cases. Each test case consists of one line. The line starts with an integer 1 ≤ n ≤ 500, followed by n integers x1 ... xn with 0 ≤ xi ≤ 50000000 for all i, the number of spectators in past games.
Output
For each test case, print YES if there is a polynomial p (with real coefficients) of degree at most 3 such that p(i) = xi for all i. Otherwise, print NO.
Example
Input: 3 1 3 5 0 1 2 3 4 5 0 1 2 4 5 Output: YES YES NO
Added by: | Adrian Kuegel |
Date: | 2010-06-21 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS OBJC PERL6 SQLITE VB.NET |
Resource: | German Collegiate Programming Contest 2010 (Author: Christoph Dittmann) |