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 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)相关推荐
- 【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 ...
- PTA甲1124 Raffle for Weibo Followers (20 point(s))
强烈推荐,刷PTA的朋友都认识一下柳神–PTA解法大佬 本文由参考于柳神博客写成 柳神的CSDN博客,这个可以搜索文章 柳神的个人博客,这个没有广告,但是不能搜索 还有就是非常非常有用的 算法笔记 全 ...
- 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(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 python解法
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 :[C++题解]哈希表、微博转发抽奖
文章目录 题目分析 题目来源 题目分析 来源:acwing 分析:开一个哈希表存已经中将的用户,避免重复发奖. 遍历所有m条姓名,从第一个中奖的开始,依次模拟即可. ac代码 #include< ...
- PAT 1124 Raffle for Weibo Followers
PAT 1124 Raffle for Weibo Followers Java 1.题意 输入:数字m,n,s,一串人名. 第s个为获奖的人,则s+n 为下一个获奖的人,如果此人已经获奖,那么则往后 ...
- 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 ...
- 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 ...
最新文章
- arcgis自动完成面怎么用_硬派的自然断裂面石材怎么用才美?
- 优质的网站结构设计有哪些好处?
- 成熟期滞后状态的云计算:应重视云存储及安全策略
- H3C SecPath防火墙GRE+IPSEC+OSPF典型配置举例
- 一次检验自己技术和耐力的碎片提取经历
- Python 代码实现模糊查询
- [zz] C++智能指针循环引用解决
- 模拟电梯1.0(类与对象实验)
- 20160419 while练习,复习
- 阿里SRE体系如何支撑24小时峰值压力、220+个国家“剁手党”?
- 游戏服务器出现问题怎么维护权益,游戏服务器出问题怎么解决
- PolarDB-X 云原生分布式数据库 > 最佳实践 > 如何选择分片数
- 力扣 比较退格的字符串
- mount远程驱动器
- MySQL 是怎么死锁的?
- 固定背景图的高度,让宽度自适应
- 基于Access的学生信息管理系统设计(下):窗体设计
- u3d联机斗地主(1):出牌规则
- ldquo;未来middot;互联网rdquo;论坛:演讲环节中规中矩,媒体访谈出现ldquo;笑话rdquo;
- 有一个棋盘,有64个方格,在第一个方格里面放1粒芝麻重量是0.00001kg,第二个里面放2粒,第三个里面放4,第四个8 ,棋盘上放的所有芝麻的重量(后一个是前一个两倍)。循环练习题。