AtCoder Grand Contest 063
C
Add Mod Operations
AtCoder
⌀ 2500
原题
← BD →
翻译中…

Problem Statement

翻译中…

You are given sequences of non-negative integers: $A = (A_1, \ldots, A_N)$ and $B=(B_1, \ldots, B_N)$.

翻译中…

Determine whether one can make $A$ equal $B$ by performing the following operation between $0$ and $N$ times, inclusive.

翻译中…
  • Operation: Choose integers $x,y$ such that $0\leq x < y\leq 10^{18}$. For every $i$, replace $A_i$ with $(A_i+x)\bmod y$.
翻译中…

If one can make $A$ equal $B$, print one way to do so.

翻译中…

Constraints

翻译中…
  • $1\leq N\leq 1000$
  • $0\leq A_i\leq 10^9$
  • $0\leq B_i\leq 10^9$
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N
A_1 \ldots A_N
B_1 \ldots B_N

翻译中…

Output

翻译中…

If one cannot make $A$ equal $B$ by performing the operation between $0$ and $N$ times, inclusive, print No.

翻译中…

No

翻译中…

If one can do so, print one way in the following format:

翻译中…

Yes
K
x_1 y_1
\vdots
x_K y_K

翻译中…

Here, $K$ is the number of operations, and $x_i, y_i$ are integers $x, y$ chosen in the $i$-th operation. These must satisfy the following:

翻译中…
  • $0\leq K\leq N$
  • $0\leq x_i < y_i \leq 10^{18}$
翻译中…

If there are multiple ways to achieve the objective, you may print any of them.

翻译中…

样例

Input #1
4
7 2 4 5
3 3 5 0
Output #1
Yes
2
3 5
3 6
One can make $A$ equal $B$ as follows. - Initially, $A = (7,2,4,5)$. - The operation with $(x,y) = (3,5)$ makes $A = (0,0,2,3)$. - The operation with $(x,y) = (3,6)$ makes $A = (3,3,5,0)$.
Input #2
1
5
3
Output #2
Yes
1
2 4
Input #3
2
3 1
3 1
Output #3
Yes
0
Input #4
2
0 0
1 2
Output #4
No
题目信息
题号
agc063_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。