https://www.acmicpc.net/problem/11871
노트에 8정도까지만 써보면 규칙이 보인다. 홀수면 (i + 1) / 2, 짝수면 (i - 2) / 2이다. 모두 xor해서 승자를 찾으면 끝이다.
코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
def ip(): return int(input())
def sp(): return str(input().rstrip())
def mip(): return map(int, input().split())
def msp(): return map(str, input().split().rstrip())
def lmip(): return list(map(int, input().split()))
def lmsp(): return list(map(str, input().split().rstrip()))
n = ip()
p = lmip()
ans = 0
for i in p:
ans ^= ((i + 1) // 2 if i & 1 else (i - 2) // 2)
print("koosaga" if ans else "cubelover")
|
cs |
'백준 문제풀이' 카테고리의 다른 글
백준 10999 - 구간 합 구하기 2 [Python] (0) | 2021.08.31 |
---|---|
백준 18937 - 왕들의 외나무다리 돌게임 [Python] (0) | 2021.08.19 |
백준 8462 - 배열의 힘 [Python] (0) | 2021.07.25 |
백준 15520 - Prime-Factor Prime [Python] (0) | 2021.07.15 |
백준 17408 - 수열과 쿼리 24 [Python] (0) | 2021.07.04 |