PAT甲级——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 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...
#include <iostream>
#include <unordered_map>
#include <string>
using namespace std;
int m, k, s;
int main()
{
cin >> m >> k >> s;
unordered_map<string,int>res;
string str;
for (int i = ; i <= m; ++i)
{
cin >> str;
if (i == s)
{
if (res[str] == )//输出过
s++;//后移动
else
{
cout << str << endl;
res[str] = ;
s += k;
}
}
}
if (res.size() == )
cout << "Keep going..." << endl;
return ;
}
PAT甲级——A1124 Raffle for Weibo Followers的更多相关文章
- PAT甲级 1124. Raffle for Weibo Followers (20)
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- 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 ...
- 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
Source: PAT A1124 Raffle for Weibo Followers (20 分) Description: John got a full mark on PAT. He was ...
- 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
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 (20 分)
1124 Raffle for Weibo Followers (20 分) John got a full mark on PAT. He was so happy that he decided ...
- PAT1124:Raffle for Weibo Followers
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
随机推荐
- Cacti 添加 CPU 监听
Cacti版本: 0.8.8a 將 http://forums.cacti.net/about29832-0-asc-135.html 网址的template下载,有1,2,4,8,12,16核心的t ...
- redis数据备份还原
安装ruby yum install ruby rubygems ruby-devel -y 安装rvm gpg2 --keyserver hkp://pool.sks-keyservers.net ...
- [转]走进 LINQ 的世界
序 在此之前曾发表过三篇关于 LINQ 的随笔: 进阶:<LINQ 标准查询操作概述>(强烈推荐) 技巧:<Linq To Objects - 如何操作字符串> 和 <L ...
- js的三种消息框alert,confirm,prompt
原文:http://blog.csdn.net/lixiang0522/article/details/7764730 <html> <head> <script typ ...
- leetcood学习笔记-168-excel表列名称
题目描述: 方法一:asiic码 class Solution: def convertToTitle(self, n: int) -> str: if (n-1)//26 == 0: retu ...
- git使用ssh连接服务器
git如何连接服务器呢? $ ssh -p 22 root@服务器ip 解释:ssh -p 端口号 登录的用户名@IP
- thinkphp 快速缓存
如果你的存储数据没有有效期的需求,那么系统还提供了一个快速缓存方法F可以用来更快的操作. 大理石平台厂家 F方法可以支持不同的存储类型,如果是文件类型的话,默认保存在DATA_PATH目录下面. 快速 ...
- vue-组件之间的通信:
组件之间的通信:一个组件被调用,那么里面的数据就需要从前者调用,因为在开发中组件时重复调用的,在页面中会反复使用,但是里面的数据是不一样的,谁调用这个组件谁就传递数据给这个组件,所以就要暴露一些接口, ...
- 动态隐藏显示窗口的标题栏(同时保持窗口的sizeable性能
今天考虑作界面的时候,想去掉窗体的标题栏,但设置 Form.BorderStyle := bsNone; 会导致窗体不可再 Sizeable (通过鼠标操作改变窗体大小),仔细翻看了相关Help也没找 ...
- 暑假集训test-8-28
大概是从我一年以来做过的最傻逼的一套题了.. 一个半小时打完三个程序三个暴力拍完以为自己AK了,开心地耍了两个小时. 结果T3要写高精,LL炸了后4个点,中间还有个点是啥都不选的,我没用0去更新又炸了 ...