原题链接:PTA | 程序设计类实验辅助教学平台
Tips:以下Python代码仅个人理解,非最优算法,仅供参考!多学习其他大佬的AC代码!
def main():
res = set()
n, step, first = map(int, input().split())
if n < first:
print('Keep going...')
return
index = first - 1 #方便数组下标0开始
for i in range(n):
name = input()
if i == index:
if name not in res:
res.add(name)
index += step
print(name)
else:
index += 1
main()