Skip to content

Commit 71704ac

Browse files
committed
[BOJ] #9665. 돌 게임 / 실버5 / 12분 / 성공
1 parent 61a4737 commit 71704ac

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
n = int(input())
2+
3+
# 승패를 기록할 배열
4+
win = [-1] * (n + 1)
5+
6+
# 초기 값 설정
7+
win[1] = 1 # SK
8+
win[2] = 0 # CY
9+
win[3] = 1 # SK
10+
11+
# 점화식으로 승패 계산
12+
for i in range(4, n + 1):
13+
if win[i-1] == 1 or win[i-3] == 1:
14+
win[i] = 0 # CY가 승리
15+
else:
16+
win[i] = 1 # SK가 승리
17+
18+
# 결과 출력
19+
if win[n] == 1:
20+
print("SK")
21+
else:
22+
print("CY")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
# 입력 받기
5+
n = int(input())
6+
7+
if n % 2 == 0:
8+
print("CY") # 짝수일 때 CY 승리
9+
else:
10+
print("SK") # 홀수일 때 SK 승리

0 commit comments

Comments
 (0)