Logo
(追記) (追記ここまで)

33102번 - Counting Pairs 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB21151266.667%

문제

Consider the binary operator $\oplus_b(x, y)$ that is defined for $b \in \{2, 4\}$ as follows. First, convert both $x$ and $y$ into base $b$. Then, for each corresponding digit pair, the resulting digit can be calculated by adding the digit pair modulo $b$. Finally, convert the result back to base ten. Notice that $\oplus_2$ is the bitwise XOR operator.

For instance, $\oplus_4(18, 7) = 21$ can be calculated as follows. The base four representations of 18ドル$ and 7ドル$ are $(102)_4$ and $(013)_4,ドル respectively. After the addition for each digit pair, the result is $(111)_4,ドル or 21ドル$ in base ten.

You are given a list of $N$ integers, $A_1, A_2, \dots , A_N$.

Determine the number of pairs $(i, j)$ such that 1ドル ≤ i < j ≤ N$ and $\oplus_2(A_i , A_j ) = \oplus_4(A_i , A_j )$.

입력

The first line consists of an integer $N$ (2ドル ≤ N ≤ 200,円 000$).

The next line consists of $N$ integers $A_i$ (0ドル ≤ A_i ≤ 10^{12}$).

출력

Output a single integer representing the number of pairs $(i, j)$ such that 1ドル ≤ i < j ≤ N$ and $\oplus_2(A_i , A_j ) = \oplus_4(A_i , A_j )$.

제한

예제 입력 1

5
2 2 0 1 3

예제 출력 1

9

The only pair that does not satisfy the requirements is $(4, 5),ドル because $\oplus_2(1, 3) = 2$ and $\oplus_4(1, 3) = 0$.

예제 입력 2

2
17 13

예제 출력 2

0

예제 입력 3

10
13 7 29 4 18 0 4 21 12 20

예제 출력 3

14

예제 입력 4

10
0 0 0 0 0 0 0 0 0 0

예제 출력 4

45

힌트

출처

ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2023 J번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /