Wrong Calculation
Time limit1sMemory limit128 MB
Given d+3 noisy samples of a degree-d polynomial with exactly one value corrupted by a large error, identify the index of the corrupted sample.
- Level
Medium6 of 10
- Topics
- Math, Brute force, Implementation
- Solved
- No attempts yet
Problem
Professor Kim Sang-geun developed a new computing engine for producing numerical tables. It computes the values of a single-variable polynomial function.
For example, if the polynomial function is , the engine reports , , , , and .
However, while coding drunk, Sang-geun made a mistake, so the engine always outputs exactly one value incorrectly. So for the polynomial above it might report instead of .
Given the values produced by the engine, write a program that finds which result was computed incorrectly.
Input
The input consists of several test cases.
The first line of each test case contains the degree of the polynomial. For example, the degree of is , and the degree of is . is at most .
The next lines contain the results in order. The polynomial function itself is not given. Every reported value is a real number greater than and less than .
The incorrect value is always one of , and its error from the correct value is greater than . Because floating-point computation cannot avoid rounding, the other values may also carry error, but that error is tiny and never exceeds .
The last line of the input contains a single .
Output
For each test case, print the position of the incorrectly computed value. If the result of is wrong, print .