1124 Raffle for Weibo Followers (20 分)
John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo – that is, he would select winners from every N followers who forwarded his post, and give away gifts. Now you are supposed to help him generate the list of winners.

Input Specification:
Each input file contains one test case. For each case, the first line gives three positive integers M (≤ 1000), N and S, being the total number of forwards, the skip number of winners, and the index of the first winner (the indices start from 1). Then M lines follow, each gives the nickname (a nonempty string of no more than 20 characters, with no white space or return) of a follower who has forwarded John’s post.

Note: it is possible that someone would forward more than once, but no one can win more than once. Hence if the current candidate of a winner has won before, we must skip him/her and consider the next one.

Output Specification:
For each case, print the list of winners in the same order as in the input, each nickname occupies a line. If there is no winner yet, print Keep going… instead.

Sample Input 1:
9 3 2
Imgonnawin!
PickMe
PickMeMeMeee
LookHere
Imgonnawin!
TryAgainAgain
TryAgainAgain
Imgonnawin!
TryAgainAgain
Sample Output 1:
PickMe
Imgonnawin!
TryAgainAgain
Sample Input 2:
2 3 5
Imgonnawin!
PickMe
Sample Output 2:
Keep going…

题意:模拟微博抽奖,第一行给出3个数(m,n,s),分别表示参与抽奖人数,获奖人数,抽奖规则(隔s个人抽一个),如果原来被抽取过,则顺延到下一个。

解题思路:用列表candidate来保存获奖者昵称,首先判断参与抽奖人数n是否小于抽奖规则s,若小于则没有获奖者,输出Keep going…,否则先将s-=1(因为列表索引从0开始),开始循环判断昵称是否在candidate中,如果在,则s+=1,不在,则判断是否满足抽奖规则(i==s),满足则将昵称添加到candidate中,并将s+=n。

m, n, s = map(int,input().split())
#m, n, s = 9,3,2
#m, n, s = 2,3,5
l = []
for i in range(m):l.append(input())
#l = ['Imgonnawin!','PickMe']
#l = ['Imgonnawin!','PickMe','PickMeMeMeee','LookHere','Imgonnawin!','TryAgainAgain','TryAgainAgain','Imgonnawin!','TryAgainAgain']
candidate = []
if s>n:print('Keep going...')
else:s -= 1for i in range(m):if l[i] in candidate:s += 1 if i == s and l[i] not in candidate:candidate.append(l[i])s += n       print('\n'.join(candidate))

PAT 1124 Raffle for Weibo Followers python解法相关推荐

  1. PAT 1124 Raffle for Weibo Followers

    PAT 1124 Raffle for Weibo Followers Java 1.题意 输入:数字m,n,s,一串人名. 第s个为获奖的人,则s+n 为下一个获奖的人,如果此人已经获奖,那么则往后 ...

  2. pat 1124 Raffle for Weibo Followers(20 分)

    1124 Raffle for Weibo Followers(20 分) John got a full mark on PAT. He was so happy that he decided t ...

  3. 【PAT (Advanced Level) Practice】1124 Raffle for Weibo Followers (20 分)

    1124 Raffle for Weibo Followers (20 分) John got a full mark on PAT. He was so happy that he decided ...

  4. PAT甲级1124 Raffle for Weibo Followers :[C++题解]哈希表、微博转发抽奖

    文章目录 题目分析 题目来源 题目分析 来源:acwing 分析:开一个哈希表存已经中将的用户,避免重复发奖. 遍历所有m条姓名,从第一个中奖的开始,依次模拟即可. ac代码 #include< ...

  5. PAT_A 1124. Raffle for Weibo Followers (20)

    1124. Raffle for Weibo Followers (20) John got a full mark on PAT. He was so happy that he decided t ...

  6. PAT(甲)1124 Raffle for Weibo Followers——未完成

    题目链接 按Ctrl单机链接,打开题目页面. 做题过程 题目分值 20 分 提交次数 分值 原因 解决方案 1 12 答案错误 重复n次 2 12 答案错误 未解决 收获:基本错题是通过样例猜题意,然 ...

  7. PTA甲1124 Raffle for Weibo Followers (20 point(s))

    强烈推荐,刷PTA的朋友都认识一下柳神–PTA解法大佬 本文由参考于柳神博客写成 柳神的CSDN博客,这个可以搜索文章 柳神的个人博客,这个没有广告,但是不能搜索 还有就是非常非常有用的 算法笔记 全 ...

  8. 1124 Raffle for Weibo Followers (20 分)

    John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers ...

  9. 1124 Raffle for Weibo Followers(map)

    John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers ...

最新文章

  1. 经过标定后的ESP32对于节能信标组充电过程测量
  2. Java 10 实战第 1 篇:局部变量类型推断
  3. 最新发布!斯坦福 CS224n 出作业视频详细讲解啦!
  4. Bootstrap 学习笔记8 下拉菜单滚动监听
  5. C++关于虚基类、构造函数、析构函数、成员对象的两个程序浅析
  6. 麻省理工学院计算机专业2018,麻省理工学院专业排名一览及最强专业推荐(QS世界大学排名)...
  7. 血型算法php,血型排行榜!(真的很准)
  8. java判断三位数的范围代码_java判断三位数的实例讲解
  9. php学到什么程度可以学thinkphp,thinkphp学习一
  10. [转载] Python字符串:大写 str.upper()
  11. 【pytorch】pytorch-LSTM
  12. Flash 3D 基础
  13. CMJ:人类微生物组研究设计、样本采集和生物信息分析指南
  14. 【jzoj2173】【DFS】无根树
  15. 云队友丨专访极飞科技彭斌:人的梦想是摁不住的!
  16. (一)Python小甲鱼入门教程——第一个小游戏001-004
  17. 安培-麦克斯韦定律修正-运动的电荷产生涡旋磁场(B=μεv×E)
  18. ubuntu20.04安装到u盘+配置美化
  19. 姚期智:为了中国计算机科学的腾飞(zz)
  20. 星辰小队针对于软件“星遇”的10天冲刺——第7天

热门文章

  1. 深入理解DirectX D3D9
  2. Macbook 删除被锁定的应用
  3. XShell 下载 安装
  4. 脊髓空洞症先知先觉早期症状
  5. 以下关于c语言程序中函数的说法正确的是( ),以下关于C语言程序中函数的说法正确的是:(  )...
  6. 百度搜索引擎排名规则有哪些呢?
  7. 《图像处理、分析与机器视觉》(第4版)阅读笔记——第五章 图像预处理
  8. android屏幕大小字体大小,Android字体大小自适应不同分辨率的解决办法
  9. C语言编程>第十七周 ⑤ 请补充fun函数,该函数的功能是:用来求出数组的最小元素在数组中的下标并存放在k所指的存储单元。
  10. python怎么去掉换行符_python去除空格和换行符的实现方法(推荐)