PAT_A1124#Raffle for Weibo Followers
Source:
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:
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...
Keys:
- 模拟题
Code:
- /*
- Data: 2019-07-04 15:00:05
- Problem: PAT_A1124#Raffle for Weibo Followers
- AC: 25:52
- 题目大意:
- 从转发微博的名单中抽奖,每隔N人送一份奖品
- 输入:
- 第一行给出,转发数M<=1000,获奖者间隔的人数N,第一个获奖者序号S>=1
- 接下来M行,转发人的昵称
- 注:若选定的获奖者如果已经获奖,则考虑下一个人
- 输出:
- 打印获奖者名单
- 基本思路:
- 从S开始遍历名单,计数器统计跳过人数,跳过n人时进行查询
- 若未获奖,计数器清零,打印姓名
- 若已获奖,计数器不变,查询下一位
- */
- #include<cstdio>
- #include<string>
- #include<map>
- #include<iostream>
- using namespace std;
- const int M=1e3+;
- string info[M];
- map<string,int> mp;
- int main()
- {
- #ifdef ONLINE_JUDGE
- #else
- freopen("Test.txt", "r", stdin);
- #endif
- int m,n,s,skip=;
- scanf("%d%d%d", &m,&n,&s);
- for(int i=; i<=m; i++)
- cin >> info[i];
- for(int i=s; i<=m; i++)
- {
- if(i==s || skip==n)
- {
- if(mp[info[i]]==){
- cout << info[i] << endl;
- mp[info[i]]=;
- skip=;
- }
- else
- continue;
- }
- skip++;
- }
- if(s > m)
- printf("Keep going...");
- return ;
- }
PAT_A1124#Raffle for Weibo Followers的更多相关文章
- PAT1124:Raffle for Weibo Followers
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- 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 ...
- 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 ...
- PAT甲级 1124. Raffle for Weibo Followers (20)
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 01java基础笔记
计算机组成:运算器,控制器,存储器,输入输出设备(外部设备I/O设备) 机器语言:机器语言,汇编语言,高级语言 人机交互:命令行方式,图形化界面交互方式 JAVA语言平台分为:J2SE,J2ME,J2 ...
- Example of dynamic programmatic description
- Suppose there are some itineraries in the Itinerary page, and you want to check on all of them. Se ...
- apache2.2.25+tomcat7.0.47集群方案
因为公司项目在线人数的增加,随着现在硬件成本越来越低,大多数的生产环境内存大多都已经达到 16G,尤其最新的阿里云,客户的机器都是配置超高的java主机,但是Java的运行环境,内存使用有限 ,这样就 ...
- datepicker时间选择弹窗
准备工作 首先请到jqueryui.com官网下载datepicker插件代码,注意官网提供了整个jquery ui的所有插件下载,但是您可以选择其中几个用到的插件下载,本文中只用到datepicke ...
- vps被封逃逸_v2+cloudflare+websocket+tls+nginx
每逢重大节日,总有那么一大部分vps凉凉,以下为能正经正常使用vps,无奈之举,此法由于多层代理,夜间速度会有影响,白天感受不明显. 由于博客园内容审查,v2_ray 中间的 下划线为分隔符,相关链接 ...
- 牛客练习赛48 C,D,E
C 小w的糖果 题意:3种操作,第一种是使pos右边的数全部+1,第二种是pos右边的数依次+k(k从1开始递增),第三种是pos右边的数依次+k^2(k从1开始递增). 解法:第一种我们很容易想到差 ...
- java反射技术主要实现类有哪些,作用分别是什么
Java反射技术主要实现类有哪些,作用分别是什么? 在JDK中,主要由以下类来实现Java反射机制,这些类都位于java.lang.reflect包中 1)Class类:代表一个类 2)Field 类 ...
- java中的继承、重载和覆盖是什么意思
继承(英语:inheritance)是面向对象软件技术当中的一个概念.如果一个类别A“继承自”另一个类别B,就把这个A称为“B的子类别”,而把B称为“A的父类别”也可以称“B是A的超类”.继承可以使得 ...
- 【Java学习笔记】Java的垃圾回收机制
搬以前写的博客[2014-12-30 15:07] 以前很少关注内存的问题,基本没有关注,这方面的小白,原因在于自己都是写的自我娱乐的小程序,不关注性能,不是提供服务.而企业级别的应用在程序稳健性方面 ...
- Circular Coloring
Circular Coloring 将n个0,m个1进行圆周排列,定义一个排列的权值为圆上所有相邻且相同的数字组成一段的段长的乘积,询问断环成链所有方案的权值之和,\(n,m\leq 5000\). ...