CCF Python題解(100分)201712-2 遊戲
阿新 • • 發佈:2018-11-13
CCF Python題解(100分)201712-2 遊戲
# _*_ coding=utf-8 _*_
__author__ = 'SRF'
__date__ = '2018/8/26 14:30'
# n 上次記錄到的值
# import sys
# sys.setrecursionlimit(1000000)
n, k = map(int, input().split())
list1 = [i for i in range(1, n + 1)]
def f(last, length):
list2 = list1[:]
for index in range(length) :
# global data
data = index + last
if data >= k:
if data % k == 0 or int(str(data)[-1]) == k:
list1.remove(list2[index])
if len(list1) == 1:
print(list1[0])
else:
f(data + 1, len(list1))
if n == 1:
print(1)
elif k == 1:
print(n)
else:
f(1, n)