CF1817C Similar Polynomials
Description
A polynomial $ A(x) $ of degree $ d $ is an expression of the form $ A(x) = a_0 + a_1 x + a_2 x^2 + \dots + a_d x^d $ , where $ a_i $ are integers, and $ a_d \neq 0 $ . Two polynomials $ A(x) $ and $ B(x) $ are called similar if there is an integer $ s $ such that for any integer $ x $ it holds that
$ $$$ B(x) \equiv A(x+s) \pmod{10^9+7}. $ $
For two similar polynomials $ A(x) $ and $ B(x) $ of degree $ d $ , you're given their values in the points $ x=0,1,\\dots, d $ modulo $ 10^9+7 $ .
Find a value $ s $ such that $ B(x) \\equiv A(x+s) \\pmod{10^9+7} $ for all integers $ x$$$.
Input Format
N/A
Output Format
N/A
Explanation/Hint
In the first example, $ A(x) \equiv x-1 \pmod{10^9+7} $ and $ B(x)\equiv x+2 \pmod{10^9+7} $ . They're similar because $ $$$B(x) \equiv A(x+3) \pmod{10^9+7}. $ $
In the second example, $ A(x) \\equiv (x+1)^2 \\pmod{10^9+7} $ and $ B(x) \\equiv (x+10)^2 \\pmod{10^9+7} $ , hence $ $ B(x) \equiv A(x+9) \pmod{10^9+7}. $ $$$