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 ...
随机推荐
- Python中的网络爬虫怎么用?
爬虫概述 (约2016年)网络爬虫个人使用和科研范畴基本不存在问题,但商业盈利范畴就要看对方了. 通过网站的Robots协议(爬虫协议)可以知道可以和不可以抓取的内容,其中User-Agent: 为允 ...
- 脚本启动SpringBoot(jar)
#!/bin/sh RESOURCE_NAME=springbsit-api.jar tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kil ...
- Java语法清单-快速回顾(开发)
Java CheatSheet 01.基础 hello,world! public static void main(String[] args) { System.out.println(" ...
- 秒懂机器学习---k临近算法(KNN)
秒懂机器学习---k临近算法(KNN) 一.总结 一句话总结: 弄懂原理,然后要运行实例,然后多解决问题,然后想出优化,分析优缺点,才算真的懂 1.KNN(K-Nearest Neighbor)算法的 ...
- Keystone controller.py & routers.py代码解析
目录 目录 Keystone WSGI 实现 controllerspy routerspy 参考文档 Keystone WSGI 实现 Keystone 项目把每个功能都分到单独的目录下,EXAMP ...
- CodeForces-1244C-The Football Season-思维
The football season has just ended in Berland. According to the rules of Berland football, each matc ...
- ps-使用通道抠图为XX换背景
第一步先载入图片 点击通道,复制蓝色通道 然后点击新的蓝色通道,图像-调整-曲线-改变输入输出, 然后用历史画笔全部填黑. 然后载入选区,复制.在图层中新建蒙版 黏贴,反向(CTRL+I)就可以了. ...
- python 17 异常
自 http://www.cnblogs.com/BeginMan/p/3171445.html 一.什么是错误,什么是异常,它们两者区别 这里解释如下:个人觉得很通俗易懂 错误是指在执行代码过程中发 ...
- sql 特殊时间值 第一天或最后一天 无计算错误
DECLARE @dt datetimeSET @dt=GETDATE() DECLARE @number intSET @number=3 --1.指定日期该年的第一天或最后一天--A. 年的第一天 ...
- 几个实用的js函数
在阅读JavaScript DOM编程艺术这本书时看到了一些比较实用的代码. //加载多个window.onload事件 function addLoadEvent(func) { var oldon ...