시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 256 MB | 115 | 105 | 93 | 94.898% |
The Hamming distance dH( ⃗v, ⃗u) between two n-dimensional vectors ⃗v = (v1, . . . , vn) and ⃗u =(u1, . . . , un) is defined as dH( ⃗v, ⃗u) = |{i : vi ≠ ui and i ∈ {1, . . . , n}}|, i.e., the number of positions at which the corresponding entries are different. For example, the Hamming distance between (1, 2, 3, 4, 5) and (1, 0, 0, 4, 5) is 2, since these two vectors differ only at the second and the third positions. Please write a program to compute the Hamming distance between two n-dimensional vectors.
On the first line there is a single integer T (T ≤ 100) indicating the number of test cases. Each test case consists of three lines. The first line of each test case contains an integer n (0 < n ≤ 50) indicating the dimension of the vectors. The second line contains n integers v1, . . . , vn, and the third line contains n integers u1, . . . , un. You may assume that v1, . . . , vn, u1, . . . , un ∈ {0, 1, . . . , 99}.
For each test case, output the Hamming distance between (v1, . . . , vn) and (u1, . . . , un).
2 3 1 2 3 3 2 1 4 1 0 1 0 1 0 1 1
2 1
ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2016 H번