목록XOR (2)
넘치게 채우기
https://www.acmicpc.net/problem/25306BOJ - 연속 XOR문제 유형: 수학, 비트마스킹문제 난이도: Gold IV시간 제한: 1초메모리 제한: 1024MB 문제준원이는 다음과 같이 A에서 B까지의 자연수들을 나열했다. A, A+1, A+2, \dots, B-2, B-1, B이 수들에 모두 비트 XOR을 취한 값을 구하라. 입력두 자연수 A, B가 공백을 사이에 두고 주어진다. 출력A 이상 B 이하인 모든 자연수들을 XOR한 값을 구하여라. 풀이물론 일일이 구하면 TLE에 걸린다.대신, f(x)를 1 ... x까지의 XOR sum이라고 해보자. 최종적으로 f(b) ^ f(a-1)을 구하면 되는 것이다. f(x), 즉 1 ... x의 XOR sum은 다음처럼 간단한 규칙을 가진..
https://leetcode.com/problems/find-the-original-array-of-prefix-xor/description/ Find The Original Array of Prefix Xor - LeetCode Can you solve this real interview question? Find The Original Array of Prefix Xor - You are given an integer array pref of size n. Find and return the array arr of size n that satisfies: * pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i]. Note that ^ denotes the b leetcode.co..