Love丶FFC's Blog
有n个小朋友围成一圈玩游戏,小朋友从1至n编号,2号小朋友坐在1号小朋友的顺时针方向,3号小朋友坐在2号小朋友的顺时针方向,……,1号小朋友坐在n号小朋友的顺时针方向。
游戏开始,从1号小朋友开始顺时针报数,接下来每个小朋友的报数是上一个小朋友报的数加1。若一个小朋友报的数为k的倍数或其末位数(即数的个位)为k,则该小朋友被淘汰出局,不再参加以后的报数。当游戏中只剩下一个小朋友时,该小朋友获胜。
例如,当n=5, k=2时:
1号小朋友报数1;
2号小朋友报数2淘汰;
3号小朋友报数3;
4号小朋友报数4淘汰;
5号小朋友报数5;
1号小朋友报数6淘汰;
3号小朋友报数7;
5号小朋友报数8淘汰;
3号小朋友获胜。
给定n和k,请问最后获胜的小朋友编号为多少?
输入一行,包括两个整数n和k,意义如题目所述。
输出一行,包含一个整数,表示获胜的小朋友编号。
5 2
3
7 3
4
对于所有评测用例,1 ≤ n ≤ 1000,1 ≤ k ≤ 9。
1.这个游戏是平常很容易接触的游戏,因此可以模拟游戏流程
2.模拟一次在现实生活中玩这个游戏的过程,创建一个列表来保存能够继续游戏的人
3.每当淘汰一个人时就从列表中删除该编号,此时剩下的人的位置就往前移动一位,因此就算有人被淘汰,游戏也必须就地继续
NOP, LuckyDigital = map(int, input().split()) # 输入小朋友的人数和淘汰数字 Child = [int(i) for i in range(1, NOP + 1)] # 还剩下的小朋友 Digital = 1 # 报数 i = 0 # 用于循环 while Child.__len__() > 1: # 游戏人数大于1人 SingleDigit = int(str(Digital)[str(Digital).__len__() - 1]) # 获取个位数 if Digital % LuckyDigital == 0 or SingleDigit == LuckyDigital: # 如果符合被淘汰的规则 Child.remove(Child[i]) # 将该小朋友淘汰 else: # 不被淘汰,继续游戏 i += 1 # 继续报数 if i == Child.__len__(): # 报完一圈 i = 0 # 从头开始 Digital += 1 # 累计报数的数字 print(Child[0])
engarma
Clematis and the large flowered hybrids are divided into categories group 1, group 2, and group 3 cialis buy online
jordans for cheap
Read reviews and was a little hesitant since I had already inputted my order. in addition to but thank god, I had no issues. particularly the received item in a timely matter, they are in new condition. in either case so happy I made the purchase. Will be definitely be purchasing again.
jordans for cheap https://www.cheapjordansstore.com/
cheap jordans
Read reviews and was a little hesitant since I had already inputted my order. otherwise but thank god, I had no issues. most notably the received item in a timely matter, they are in new condition. situation so happy I made the purchase. Will be definitely be purchasing again.
cheap jordans https://www.cheapauthenticjordanshoes.com/
louis vuitton outlet sale online
Read reviews and was a little hesitant since I had already inputted my order. while well as but thank god, I had no issues. decline received item in a timely matter, they are in new condition. in either case so happy I made the purchase. Will be definitely be purchasing again.
louis vuitton outlet sale online https://www.louisvuittonsoutletonline.com/
authentic cheap jordans
Read reviews and was a little hesitant since I had already inputted my order. or perhaps but thank god, I had no issues. decline received item in a timely matter, they are in new condition. blue jays so happy I made the purchase. Will be definitely be purchasing again.
authentic cheap jordans https://www.realjordansretro.com/
Preliaf
buy cialis usa In addition, maintaining a healthy diet that provides plenty of protein, iron, and vitamins is one of the best ways to flush unwanted fluids from your body
Preliaf
Monitor Closely 1 enzalutamide will decrease the level or effect of levamlodipine by affecting hepatic intestinal enzyme CYP3A4 metabolism cheapest finasteride on the web
RoEHNfAs
vardenafil cheap 5 10 mg Approved for use in 2002