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.
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.
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.
Input: 3 1 3 5 0 1 2 3 4 5 0 1 2 4 5 Output: YES YES NO