[20250818] BOJ / P5 / AND, OR, XOR 2 / 권혁준 #687
Merged
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/31422
🧭 풀이 시간
70분
👀 체감 난이도
✏️ 문제 설명
길이$N$ 인 수열 $A_1, A_2, \cdots, A_N$ 이 있다.$998,244,353$ 으로 나눈 나머지를 구해보자.

다음 세 값을 각각
🔍 풀이 방법
비트 연산(AND, OR, XOR)은 각 비트별로 따로따로 생각해줘도 된다.
그러면 각 원소가 해당 비트를 포함하는지 여부에 따라 수열의 원소는 0,1 꼴로 바뀌게 된다.
AND와 OR은 각각 해당 구간에 1만 포함 / 0만 포함하는 경우만 세어주면 된다.
XOR은 수열의 원소를 0,1로 바꾼 꼴에서 누적 합을 구한 뒤 잘 세어주면 된다.
⏳ 회고
왜 틀렸는지도 모르겠고 왜 맞았는지도 모르겠다