Add Mod Operations

AtCoder
IDagc063_c
Time2000ms
Memory256MB
Difficulty
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$ [samples]
Samples
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
API Response (JSON)
{
  "problem": {
    "name": "Add Mod Operations",
    "description": {
      "content": "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$ an",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "agc063_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given sequences of non-negative integers: $A = (A_1, \\ldots, A_N)$ and $B=(B_1, \\ldots, B_N)$.\nDetermine whether one can make $A$ equal $B$ by performing the following operation between $0$ an...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments