发现Github也可以写blog,转战GitHub------------->>>> U•ェ•*U---------<<<<<<

以后偶尔写写csdn,大多在github…

'''
其实用公式法更快:f(n, m) = (f(n - 1) + m) mod n
'''


def josef(n, m):
    number = []

    for i in range(n):
        number.append(i + 1)

    remove_index = 0
    while len(number) != 1:
        remove_index = (remove_index + m - 1) % len(number)
        number.remove(number[remove_index])

    return number[0]


while True:
    n, m = map(int, input().split())
    print(josef(n, m))

你可能感兴趣的:(oj题解,pythonLearning,python)