No.1828 Except 3
タグ : / 解いたユーザー数 140
作問者 :
Problem Statement
2022/02/01 21:36 A confusingly worded passage in the problem statement has been corrected.
You are given sequences $A,B,C$ of length $N$. How many tuples of integers $(i,j,k)\ (1≦i,j,k≦N)$ satisfy the following?
・Each of the values $A_i,B_j,C_k$ is a number that does not have $3$ as a divisor
Input
$N$ $A_1\ A_2\ ...\ A_N$ $B_1\ B_2\ ...\ B_N$ $C_1\ C_2\ ...\ C_N$
・$1≦N≦10^4$
・$1≦A_i,B_j,C_k≦10^9$
・All input values are integers
Output
Output the answer.
Sample
Sample 1
Input
4 3 5 12 6 9 2 5 3 16 1 15 9
Output
4
The $4$ tuples $(i,j,k)=(2,2,1),(2,2,2),(2,3,1),(2,3,2)$ satisfy the condition.
Sample 2
Input
3 3 2 9 6 10 12 3 6 1
Output
1
Only $(2,2,3)$ satisfies the condition.
Sample 3
Input
3 3 2 9 6 10 12 3 6 9
Output
0
The combination $(i,j)=(2,2)$ exists, but all elements of the sequence $C$ have $3$ as a divisor. Therefore, no combination $(i,j,k)$ exists.
Sample 4
Input
7 3 45 10 8 48 53 76 52 19 86 3 9 90 63 1 8 4 3 9 10 3
Output
48
Although not shown in the sample inputs, note that the answer may not fit in a $32$-bit integer type.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。