Polynomial in a Black Box

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

This is an interactive problem.

Alice has a black box which works with integers modulo m=109+7m = 10^{9} + 7. If a user types a number xx on the keyboard of the box, the screen shows the number equal to the value of the polynomial p(x)=(a_dxd+a_d1xd1++a_1x1+a_0)modmp (x) = (a\_{d} x^{d} + a\_{d - 1} x^{d - 1} + \ldots + a\_{1} x^{1} + a\_{0}) \bmod m. The degree dd of the polynomial is unknown, as are its coefficients a_ia\_{i}. It is only known that 0d100 \le d \le 10 and a_d0a\_d \ne 0.

Alice can type several numbers xx and learn the values of the polynomial for these numbers. Help her find the degree dd of the polynomial. She can input an xx at most d+3d + 3 times.

힌트

In each test, the degree and the coefficients of the polynomial p(x)p (x) are chosen and fixed in advance.

In the example, which is also the first test in the testing system, p(x)=x2+1,000,000,005p (x) = x^2 + 1\\,000\\,000\\,005. All other tests were created as follows: first, the degree dd was chosen (0d100 \le d \le 10), and after that, one of the polynomials of such degree was chosen as p(x)p (x) uniformly at random.