

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 200 点
問題文
2 つの N 次元ベクトル A = (A_1, A_2, A_3, \dots, A_N), B = (B_1, B_2, B_3, \dots, B_N) が与えられます。
A と B の内積が 0 かどうかを判定してください。
すなわち、A_1B_1 + A_2B_2 + A_3B_3 + \dots + A_NB_N = 0 かどうかを判定してください。
制約
- 1 \le N \le 100000
- -100 \le A_i \le 100
- -100 \le B_i \le 100
- 入力に含まれる値は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 A_3 \dots A_N B_1 B_2 B_3 \dots B_N
出力
A と B の内積が 0 ならば Yes
を、0 でないならば No
を出力せよ。
入力例 1
2 -3 6 4 2
出力例 1
Yes
A と B の内積は (-3) \times 4 + 6 \times 2 = 0 です。
入力例 2
2 4 5 -1 -3
出力例 2
No
A と B の内積は 4 \times (-1) + 5 \times (-3) = -19 です。
入力例 3
3 1 3 5 3 -6 3
出力例 3
Yes
A と B の内積は 1 \times 3 + 3 \times (-6) + 5 \times 3 = 0 です。
Score : 200 points
Problem Statement
Given are two N-dimensional vectors A = (A_1, A_2, A_3, \dots, A_N) and B = (B_1, B_2, B_3, \dots, B_N).
Determine whether the inner product of A and B is 0.
In other words, determine whether A_1B_1 + A_2B_2 + A_3B_3 + \dots + A_NB_N = 0.
Constraints
- 1 \le N \le 100000
- -100 \le A_i \le 100
- -100 \le B_i \le 100
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N A_1 A_2 A_3 \dots A_N B_1 B_2 B_3 \dots B_N
Output
If the inner product of A and B is 0, print Yes
; otherwise, print No
.
Sample Input 1
2 -3 6 4 2
Sample Output 1
Yes
The inner product of A and B is (-3) \times 4 + 6 \times 2 = 0.
Sample Input 2
2 4 5 -1 -3
Sample Output 2
No
The inner product of A and B is 4 \times (-1) + 5 \times (-3) = -19.
Sample Input 3
3 1 3 5 3 -6 3
Sample Output 3
Yes
The inner product of A and B is 1 \times 3 + 3 \times (-6) + 5 \times 3 = 0.