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…

  • 分析:这题很简单!一次AC!可是考试的时候,不熟悉考试环境,结果做了整整半小时!
  • code:
#include<iostream>
#include<vector>
using namespace std;
int M;
int N;
int S;string tmp_s;
vector<string>que;
int main()
{cin>>M>>N>>S;int tmp_a=S-1;bool isNo=true;for(int i=0;i<M;i++){cin>>tmp_s;for(int j=0;j<que.size();j++){if(tmp_s==que.at(j)){tmp_a++;}}if(i==tmp_a){isNo=false;cout<<tmp_s<<endl;que.push_back(tmp_s);tmp_a+=N;}}if(isNo==true)cout<<"Keep going..."<<endl;return 0;
}

PAT_A 1124. Raffle for Weibo Followers (20)相关推荐

  1. 【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 ...

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

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

  3. PAT-1124. Raffle for Weibo Followers (20)

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

  4. 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 ...

  5. PAT 1124 Raffle for Weibo Followers python解法

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

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

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

  7. PAT 1124 Raffle for Weibo Followers

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

  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. arcgis自动完成面怎么用_硬派的自然断裂面石材怎么用才美?
  2. 优质的网站结构设计有哪些好处?
  3. 成熟期滞后状态的云计算:应重视云存储及安全策略
  4. H3C SecPath防火墙GRE+IPSEC+OSPF典型配置举例
  5. 一次检验自己技术和耐力的碎片提取经历
  6. Python 代码实现模糊查询
  7. [zz] C++智能指针循环引用解决
  8. 模拟电梯1.0(类与对象实验)
  9. 20160419 while练习,复习
  10. 阿里SRE体系如何支撑24小时峰值压力、220+个国家“剁手党”?
  11. 游戏服务器出现问题怎么维护权益,游戏服务器出问题怎么解决
  12. PolarDB-X 云原生分布式数据库 > 最佳实践 > 如何选择分片数
  13. 力扣 比较退格的字符串
  14. mount远程驱动器
  15. MySQL 是怎么死锁的?
  16. 固定背景图的高度,让宽度自适应
  17. 基于Access的学生信息管理系统设计(下):窗体设计
  18. u3d联机斗地主(1):出牌规则
  19. ldquo;未来middot;互联网rdquo;论坛:演讲环节中规中矩,媒体访谈出现ldquo;笑话rdquo;
  20. 有一个棋盘,有64个方格,在第一个方格里面放1粒芝麻重量是0.00001kg,第二个里面放2粒,第三个里面放4,第四个8 ,棋盘上放的所有芝麻的重量(后一个是前一个两倍)。循环练习题。

热门文章

  1. “机器学习实战”刻意练习——回归问题:线性回归(最小二乘、岭回归、逐步回归)
  2. 计算机网络 数据链路层——广播信道 简记
  3. 线性代数学习(一):大致矩阵介绍
  4. 4.1 简单题 - D 加油冲鸭(C语言)
  5. 往Oracle数据库中插入NCLOB/CLOB类型数据
  6. html 中设置只读的textarea控件颜色
  7. 有什么网站是python做的_自学python有什么网站
  8. Axure RP8-实战案例_总目录
  9. Axure 简单Demo
  10. 食品行业的新科技总结