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 <stdio.h>
#include <string>
#include <iostream>
#include <set>
using namespace std;
const int maxn=;
string res[maxn];
set<string> st;
int main(){
string s;
int m,n,p;
cin>>m>>n>>p;
for(int i=;i<=m;i++){
cin>>res[i];
}
if(m<p){
printf("Keep going...");
return ;
}
for(int i=p;i<=m;i+=n){
if(st.find(res[i])==st.end()){
st.insert(res[i]);
printf("%s\n",res[i].c_str());
}
else{
while(st.find(res[i])!=st.end() && i<=m){
i++;
}
if(i<=m){
st.insert(res[i]);
printf("%s\n",res[i].c_str());
}
}
}
}

注意点:题目要看清楚,把n和s搞反了一直答案错误。题目其实没有说清楚的一点是已经中奖的人跳到下一个以后,再下一个中奖的人是按照原来的顺序加间隔,还是新的那个人加间隔。

ps:用set好像不太好,大佬都是用的map直接可以判断是否为0,map创建int时默认为0。也有一边输入一边处理的,在线处理很棒。

PAT A1124 Raffle for Weibo Followers (20 分)——数学题的更多相关文章

  1. 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 ...

  2. 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 ...

  3. PAT甲级 1124. Raffle for Weibo Followers (20)

    1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. PAT_A1124#Raffle for Weibo Followers

    Source: PAT A1124 Raffle for Weibo Followers (20 分) Description: John got a full mark on PAT. He was ...

  8. PAT1124:Raffle for Weibo Followers

    1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...

  9. 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 ...

随机推荐

  1. 【github&&git】3、git图像化界面GUI的使用

    GIT学习笔记 一.        基础内容 1.git是一个版本控制软件,与svn类似,特点是分布式管理,不需要中间总的服务器,可以增加很多分支. 2.windows下的git叫msysgit,下载 ...

  2. Java集合之LinkedHashMap源码分析

    概述 HashMap是无序的, 即put的顺序与遍历顺序不保证一样. LinkedHashMap是HashMap的一个子类, 它通过重写父类的相关方法, 实现自己的功能. 它保留插入的顺序. 如果需要 ...

  3. blfs(systemv版本)学习笔记-总页

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! lfs(systemv版本)学习笔记:https://www.cnblogs.com/renren-study-notes/p/ ...

  4. Installing Fonts programatically C#

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  5. drupal7常用函数

    1.获取当前启用的管理员主题名称: $admin_theme = variable_get('admin_theme');

  6. SSM环境搭建

    流程 1,maven 依赖 2,spring 配置文件 3,mybatis 配置文件 4,springMVC 配置文件 5,web.xml pom依赖 1,定义版本 <properties> ...

  7. sqlserver 将 “用 特定字符 分隔的一个字段” 拆分成多个字段,然后两个表之间数据更新

    将源TXT文件sourceFile_table.txt导入数据库,生成新表dbo.sourceFile_table.新增字段lon.lat.shi.xian 源表dbo.sourceFile_tabl ...

  8. Jenkins的配置从节点中默认没有Launch agent via Java Web Start,该如何配置使用

    Jenkins的配置从节点中默认没有Launch agent via Java Web Start,如下图所示,而这种启动方式在Windows上是最方便的. 如何设置才能让出来呢? 1:打开" ...

  9. Centos 下添加开机自启动服务和脚本

    最近刚玩Centos7的系统,跟Centos6还是很多方面有改变的,这里记录一下怎么在Centos7下添加开机自启动脚本和服务的方法. 1.添加开机自启服务 我这里以docker 服务为例,设置如下两 ...

  10. Install Google Chrome on Fedora 28/27, CentOS/RHEL 7.5 (在 fedora 28 等 上 安装 chrome)

    今天在使用 fedora 安装 chrome 的时候遇到了问题,今天进行将安装过程进行记录下来.需要安装第三方软件仓库. 我们需要进行安装 fedora-workstation-repositorie ...