RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 COCI00697

Xor

설명

Fran recently learned the operation xor, which for two integers \(x\) and \(y\) returns
the result by applying the bitwise exclusive or (exclusive \(or\)). The operation xor,
denoted as ⊕, compares the corresponding bits of the numbers \(x\) and \(y\) and sets
the result bit at each position according to the following rule:
• If the bits at the corresponding position are different (0 and 1, or 1 and 0),
then the result bit is 1.
• If the bits are the same (0 and 0, or 1 and 1), then the result bit is 0.
For example, for \(x = 5\) and \(y = 3\), the binary representations are: \(x = 101_{2}\), \(y = 011_{2}\). Applying xor to
the corresponding bits gives \(x\)\(y = 101_{2}\)\(011_{2}\) = \(110_{2}\) = 6. In other words, 5 ⊕\(3 = 6\).
Fran received an array of \(n\) integers \(a_{1}\), \(a_{2}\), . . . , \(a_{n}\) and decided to do the following:
1. For every pair of indices (i, j) where \(1 \le i \le j \le n\), he calculated the sum \(a_{i} + a_{j}\).
2. Now he wants to calculate the result of the xor of all the obtained sums.
Help Fran calculate the required result.

제약
입력 형식

In the first line of input, there is \(n\) (\(1 \le n \le 5 \cdot 10^{5}\)), the length of the array.
In the second line, there are \(n\) numbers \(a_{1}\), \(a_{2}\), . . . , \(a_{n}\) (\(0 \le a_{i} < 2^{30}\)) as described in the problem statement.

출력 형식

In the only line of output, print the required result.

서브태스크
서브태스크점수설명

1

7점

\(n \le 2000\)

2

17점

\(a_{i} < 2^{10}\) for every \(i\)

3

45점

\(n \le 10^{5}\)

4

21점

No additional constraints.

예제 1
입력
3
2 4 5
출력
14
예제 2
입력
4
6 7 3 1
출력
3
예제 3
입력
7
2 3 5 7 9 11 13
출력
6
설명

Clarification of the first example:
The sums are 2 + 2 = 4, 2 + 4 = 6, 2 + 5 = 7, 4 + 4 = 8, 4 + 5 = 9, and 5 + 5 = 10. The result is
4 ⊕6 ⊕7 ⊕8 ⊕9 ⊕10 = 14.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2024/2025 Contest 4

평가 및 의견

Xor

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Xor

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8