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...
题意:从转发微博的人中抽奖,每n个人抽一次,如果当前人已经中过奖考虑下一个。
坑点:如果序号A已经中过奖,考虑A+1,如果A+1也中过奖,要考虑A+2。。。另外如果A+2没中奖,则A+2中奖,下一次需要从A+2+n再开始遍历。。。(感觉题意不太明确)
/** * Copyright(c) * All rights reserved. * Author : Mered1th * Date : 2019-02-28-13.02.01 * Description : A1124 */ #include<cstdio> #include<cstring> #include<iostream> #include<cmath> #include<algorithm> #include<string> #include<unordered_set> #include<map> #include<vector> #include<set> #include<unordered_map> using namespace std; ; string str[maxn]; unordered_map<string,int> mp; int main(){ #ifdef ONLINE_JUDGE #else freopen("1.txt", "r", stdin); #endif int m,n,s; bool flag=false; scanf("%d%d%d",&m,&n,&s); ;i<=m;i++){ cin>>str[i]; } for(int i=s;i<=m;i=i+n){ ){ cout<<str[i]<<endl; mp[str[i]]=; flag=true; } else{ ;j<=m;j++){ ){ cout<<str[j]<<endl; flag=true; mp[str[j]]=; i=j; break; } } } } if(flag==false){ cout<<"Keep going..."; } ; }
1124 Raffle for Weibo Followers (20 分)的更多相关文章
- 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 ...
- PAT甲级 1124. Raffle for Weibo Followers (20)
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 ...
- 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 ...
- 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 ...
- 1124 Raffle for Weibo Followers
题意:水题,直接贴代码了.(为什么我第一遍做的时候代码写的那么烦?) 代码: #include <iostream> #include <string> #include &l ...
- PAT1124:Raffle for Weibo Followers
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- PAT_A1124#Raffle for Weibo Followers
Source: PAT A1124 Raffle for Weibo Followers (20 分) Description: John got a full mark on PAT. He was ...
- 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 ...
随机推荐
- 【HDOJ1043】【康拓展开+BFS】
http://acm.hdu.edu.cn/showproblem.php?pid=1043 Eight Time Limit: 10000/5000 MS (Java/Others) Memo ...
- 【mybatis源码学习】mybtias扩展点
[1]org.apache.ibatis.reflection.ReflectorFactory 该扩展点,主要是对javaBean对象,进行反射操作. org.apache.ibatis.refle ...
- zabbix监控mysql最简单的方法
该实验基于我的上一篇文章监控第一台主机的基础上 首先,因为水平有限,我选择直接关闭了防火墙和SELinux. 环境: 两台centos7,服务器端IP是192.168.200.128(以下简称主机), ...
- MySQL 5.7--多源复制(非GTID模式)
==================================================== 在MYSQL5.7版本中引入多源复制,一个从库允许复制多个主库的数据,每个主库被配置为一个单独 ...
- 使用btrace需要注意的几个问题
1. @ProbeClassName String clazz 此处String不能写为java.lang.String 2. location=@Location(Kind.RETURN) publ ...
- 本地开发不用改hosts 也可以绑定域名开发
以往我们在开发 web 应用时,为了模拟生产环境都会修改系统中的hosts 文件,加入一个域名指向 127.0.0.1,绑定到开发目录,如下: 但是在 Chrome 中有一个域名是可以不用修改 hos ...
- 20165308 学习基础和C语言基础调查
学习基础和C语言基础调查 技能学习 我认为给学生具体的, 能实践的, 能马上看到因果关系的教材和练习, 是激发学生兴趣, 好奇心, 求知欲的好方法. -- 引用自<做中学> 老师博客中注重 ...
- Java单播、广播、多播(组播)---转
一.通信方式分类 在当前的网络通信中有三种通信模式:单播.广播和多播(组播),其中多播出现时间最晚,同时具备单播和广播的优点. 单播:单台主机与单台主机之间的通信 广播:当台主机与网络中的所有主机通信 ...
- JDK动态代理实例
最近看<深入浅出MyBatis技术原理与实战>这本书时,里面讲到Mapper接口的内部实现是通过JDK动态代理生成实现类,联想到之前看<SPRING技术内幕>这本书里也常常提到 ...
- js 递归
我理解的递归就是自己调用自己,也就是函数在调用的时候会形成 call stack 调用堆栈.这些数据是用来函数调用完成后,回复之前的函数环境或者局部变量之类的,一般这个都有大小限制,不可能无限生成函数 ...