A15955 | Similar Polynomials
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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}. $$ </p><p>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$ .</p><p>Find a value $s$ such that $B(x) \\equiv A(x+s) \\pmod{10^9+7}$ for all integers $x$$$.
$$$$ B(x) \equiv A(x+s) \pmod{10^9+7}. $$ </p><p>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$ .</p><p>Find a value $s$ such that $B(x) \\equiv A(x+s) \\pmod{10^9+7}$ for all integers $x$$$.
输入格式
The first line contains a single integer $d$ ( $1 \le d \le 2\,500\,000$ ).
The second line contains $d+1$ integers $A(0), A(1), \ldots, A(d)$ ( $0 \le A(i) < 10^9+7$ ) — the values of the polynomial $A(x)$ .
The third line contains $d+1$ integers $B(0), B(1), \ldots, B(d)$ ( $0 \le B(i) < 10^9+7$ ) — the values of the polynomial $B(x)$ .
It is guaranteed that $A(x)$ and $B(x)$ are similar and that the leading coefficients (i.e., the coefficients in front of $x^d$ ) of $A(x)$ and $B(x)$ are not divisible by $10^9+7$ .
The second line contains $d+1$ integers $A(0), A(1), \ldots, A(d)$ ( $0 \le A(i) < 10^9+7$ ) — the values of the polynomial $A(x)$ .
The third line contains $d+1$ integers $B(0), B(1), \ldots, B(d)$ ( $0 \le B(i) < 10^9+7$ ) — the values of the polynomial $B(x)$ .
It is guaranteed that $A(x)$ and $B(x)$ are similar and that the leading coefficients (i.e., the coefficients in front of $x^d$ ) of $A(x)$ and $B(x)$ are not divisible by $10^9+7$ .
输出格式
Print a single integer $s$ ( $0 \leq s < 10^9+7$ ) such that $B(x) \equiv A(x+s) \pmod{10^9+7}$ for all integers $x$ .
If there are multiple solutions, print any.
If there are multiple solutions, print any.
输入输出样例
输入 #1
1 1000000006 0 2 3
输出 #1
3
输入 #2
2 1 4 9 100 121 144
输出 #2
9
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}. $$ </p><p>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}. $$$$
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted