Source:

PAT A1124 Raffle for Weibo Followers (20 分)

Description:

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:

  1. 9 3 2
  2. Imgonnawin!
  3. PickMe
  4. PickMeMeMeee
  5. LookHere
  6. Imgonnawin!
  7. TryAgainAgain
  8. TryAgainAgain
  9. Imgonnawin!
  10. TryAgainAgain

Sample Output 1:

  1. PickMe
  2. Imgonnawin!
  3. TryAgainAgain

Sample Input 2:

  1. 2 3 5
  2. Imgonnawin!
  3. PickMe

Sample Output 2:

  1. Keep going...

Keys:

  • 模拟题

Code:

  1. /*
  2. Data: 2019-07-04 15:00:05
  3. Problem: PAT_A1124#Raffle for Weibo Followers
  4. AC: 25:52
  5.  
  6. 题目大意:
  7. 从转发微博的名单中抽奖,每隔N人送一份奖品
  8. 输入:
  9. 第一行给出,转发数M<=1000,获奖者间隔的人数N,第一个获奖者序号S>=1
  10. 接下来M行,转发人的昵称
  11. 注:若选定的获奖者如果已经获奖,则考虑下一个人
  12. 输出:
  13. 打印获奖者名单
  14.  
  15. 基本思路:
  16. 从S开始遍历名单,计数器统计跳过人数,跳过n人时进行查询
  17. 若未获奖,计数器清零,打印姓名
  18. 若已获奖,计数器不变,查询下一位
  19. */
  20. #include<cstdio>
  21. #include<string>
  22. #include<map>
  23. #include<iostream>
  24. using namespace std;
  25. const int M=1e3+;
  26. string info[M];
  27. map<string,int> mp;
  28.  
  29. int main()
  30. {
  31. #ifdef ONLINE_JUDGE
  32. #else
  33. freopen("Test.txt", "r", stdin);
  34. #endif
  35.  
  36. int m,n,s,skip=;
  37. scanf("%d%d%d", &m,&n,&s);
  38. for(int i=; i<=m; i++)
  39. cin >> info[i];
  40. for(int i=s; i<=m; i++)
  41. {
  42. if(i==s || skip==n)
  43. {
  44. if(mp[info[i]]==){
  45. cout << info[i] << endl;
  46. mp[info[i]]=;
  47. skip=;
  48. }
  49. else
  50. continue;
  51. }
  52. skip++;
  53. }
  54. if(s > m)
  55. printf("Keep going...");
  56.  
  57. return ;
  58. }

PAT_A1124#Raffle for Weibo Followers的更多相关文章

  1. PAT1124:Raffle for Weibo Followers

    1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...

  2. PAT 1124 Raffle for Weibo Followers

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

  3. 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 (20)

    1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...

  5. 1124 Raffle for Weibo Followers[简单]

    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(20 分)

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

  7. PAT甲级:1124 Raffle for Weibo Followers (20分)

    PAT甲级:1124 Raffle for Weibo Followers (20分) 题干 John got a full mark on PAT. He was so happy that he ...

  8. A1124. Raffle for Weibo Followers

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

  9. PAT A1124 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 ...

随机推荐

  1. 01java基础笔记

    计算机组成:运算器,控制器,存储器,输入输出设备(外部设备I/O设备) 机器语言:机器语言,汇编语言,高级语言 人机交互:命令行方式,图形化界面交互方式 JAVA语言平台分为:J2SE,J2ME,J2 ...

  2. Example of dynamic programmatic description

    - Suppose there are some itineraries in the Itinerary page, and you want to check on all of them. Se ...

  3. apache2.2.25+tomcat7.0.47集群方案

    因为公司项目在线人数的增加,随着现在硬件成本越来越低,大多数的生产环境内存大多都已经达到 16G,尤其最新的阿里云,客户的机器都是配置超高的java主机,但是Java的运行环境,内存使用有限 ,这样就 ...

  4. datepicker时间选择弹窗

    准备工作 首先请到jqueryui.com官网下载datepicker插件代码,注意官网提供了整个jquery ui的所有插件下载,但是您可以选择其中几个用到的插件下载,本文中只用到datepicke ...

  5. vps被封逃逸_v2+cloudflare+websocket+tls+nginx

    每逢重大节日,总有那么一大部分vps凉凉,以下为能正经正常使用vps,无奈之举,此法由于多层代理,夜间速度会有影响,白天感受不明显. 由于博客园内容审查,v2_ray 中间的 下划线为分隔符,相关链接 ...

  6. 牛客练习赛48 C,D,E

    C 小w的糖果 题意:3种操作,第一种是使pos右边的数全部+1,第二种是pos右边的数依次+k(k从1开始递增),第三种是pos右边的数依次+k^2(k从1开始递增). 解法:第一种我们很容易想到差 ...

  7. java反射技术主要实现类有哪些,作用分别是什么

    Java反射技术主要实现类有哪些,作用分别是什么? 在JDK中,主要由以下类来实现Java反射机制,这些类都位于java.lang.reflect包中 1)Class类:代表一个类 2)Field 类 ...

  8. java中的继承、重载和覆盖是什么意思

    继承(英语:inheritance)是面向对象软件技术当中的一个概念.如果一个类别A“继承自”另一个类别B,就把这个A称为“B的子类别”,而把B称为“A的父类别”也可以称“B是A的超类”.继承可以使得 ...

  9. 【Java学习笔记】Java的垃圾回收机制

    搬以前写的博客[2014-12-30 15:07] 以前很少关注内存的问题,基本没有关注,这方面的小白,原因在于自己都是写的自我娱乐的小程序,不关注性能,不是提供服务.而企业级别的应用在程序稳健性方面 ...

  10. Circular Coloring

    Circular Coloring 将n个0,m个1进行圆周排列,定义一个排列的权值为圆上所有相邻且相同的数字组成一段的段长的乘积,询问断环成链所有方案的权值之和,\(n,m\leq 5000\). ...