409473: GYM103575 D Add and Multiply

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Add and Multiplytime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

You are given two arrays $$$a$$$ and $$$b$$$ of length $$$n$$$. Find an array of non-negative integers $$$c$$$ of length $$$n$$$ such that if you add it to $$$a$$$ and $$$b$$$ element-wise, then the product of the numbers in each one of these arrays is the same, or say that it's impossible.

Formally, you need to find a sequence of non-negative integers $$$c_1, c_2, \ldots, c_n$$$, such that $$$(a_1 + c_1) \cdot (a_2 + c_2) \cdot \ldots \cdot (a_n + c_n) = (b_1 + c_1) \cdot (b_2 + c_2) \cdot \ldots \cdot (b_n + c_n)$$$.

Input

The first line contains one integer $$$n$$$ ($$$1 \le n \le 100\,000$$$).

The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 1000$$$).

The third line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le b_i \le 1000$$$).

Output

If such array does not exist, output "NO". Otherwise, print "YES" in the first line. Then, print $$$n$$$ integers $$$c_1, c_2 \ldots c_n$$$ ($$$0 \le c_i \le 10^{18}$$$) — the solution to the problem. If there are multiple solutions, print any of them. It's guaranteed that if a solution exists, then there is a solution that fits the constraints.

Scoring
SubtaskPointsConstraints
19$$$n \le 2; a_i, b_i \le 10$$$
225$$$n \le 2$$$
319$$$n \le 3$$$
418$$$a_i, b_i \le 2$$$
529No additional constraints
ExampleInput
4
1 2 5 4
6 1 6 2
Output
YES
6 4 1 1 

加入题单

算法标签: