[20260308] BOJ / G1 / XOR 합 3 / 권혁준#2004
Merged
ShinHeeEul merged 1 commit intomainfrom Mar 8, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://www.acmicpc.net/problem/13710
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
수열의 XOR 합이란 수열에 들어있는 모든 원소를 다 XOR한 값이다.
수열 A 주어졌을 때, A의 모든 연속하는 부분 수열의 XOR 합을 더한 값을 구하는 프로그램을 작성하시오.
🔍 풀이 방법
XOR 연산은 bitwise 연산이다. (비트 단위로 적용된다.)
비트 별로 독립적으로 합을 구해줘도 된다.
각 비트 별로 수열을 재구성하면 반드시 0과 1 만으로 구성된다.
재구성한 수열에서 연속 부분 수열이 홀수인 경우의 수를 구한 뒤, 해당 비트의 실제 값만큼 곱해주면 된다.
연속 부분 수열이 홀수라는 것은, 누적 합 배열에서 홀수 - 짝수 or 짝수 - 홀수인 경우 뿐이고, 이를 odd, even 변수로 누적해서 관리해줬다.
⏳ 회고
eez