공주 구하기 (큐)

이세진·2022년 4월 15일
0

코테준비

목록 보기
36/87

생성일: 2022년 1월 27일 오후 5:32

구현 코드

# 공주 구하기
import sys
#sys.stdin = open("input.txt", "rt")
n, k = map(int, input().split())
l = []
for i in range(n):
    l.append(i+1)

cnt = 1

while len(l) != 1:
    if cnt != k:
        a = l.pop(0)
        l.append(a)
        cnt += 1
    else:
        l.pop(0)
        cnt = 1

print(l[0])
profile
나중은 결코 오지 않는다.

0개의 댓글