Source:

PAT A1124 Raffle for Weibo Followers (20 分)

Description:

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

Keys:

  • 模拟题

Code:

 /*
Data: 2019-07-04 15:00:05
Problem: PAT_A1124#Raffle for Weibo Followers
AC: 25:52 题目大意:
从转发微博的名单中抽奖,每隔N人送一份奖品
输入:
第一行给出,转发数M<=1000,获奖者间隔的人数N,第一个获奖者序号S>=1
接下来M行,转发人的昵称
注:若选定的获奖者如果已经获奖,则考虑下一个人
输出:
打印获奖者名单 基本思路:
从S开始遍历名单,计数器统计跳过人数,跳过n人时进行查询
若未获奖,计数器清零,打印姓名
若已获奖,计数器不变,查询下一位
*/
#include<cstdio>
#include<string>
#include<map>
#include<iostream>
using namespace std;
const int M=1e3+;
string info[M];
map<string,int> mp; int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("Test.txt", "r", stdin);
#endif int m,n,s,skip=;
scanf("%d%d%d", &m,&n,&s);
for(int i=; i<=m; i++)
cin >> info[i];
for(int i=s; i<=m; i++)
{
if(i==s || skip==n)
{
if(mp[info[i]]==){
cout << info[i] << endl;
mp[info[i]]=;
skip=;
}
else
continue;
}
skip++;
}
if(s > m)
printf("Keep going..."); return ;
}

PAT_A1124#Raffle for Weibo Followers的更多相关文章

  1. PAT1124:Raffle for Weibo Followers

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

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

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

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

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

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

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

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

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

随机推荐

  1. 2的N次方求解-----C++

    2的N次方求解,一般情况如果不超出C/C++基本数据类型的表达范围,这个问题及其容易,但是如果N的值十分的大,以致于超出基本数据类型表达范围 下面的程序正是解决2的N次方这个大数精确求解的源码 #in ...

  2. linux 安装memcache

    cd /usr/local/src  #进入软件包存放目录wget http://pecl.php.net/get/memcache-2.2.6.tgz  #下载tar zxvf memcache-2 ...

  3. (14)C++ 代码重用

    valarray<,,,, };//进行高速的数字计算 int a= val.size();//返回包含元素个数 int b= val.sum();//元素总和 int c= val.max() ...

  4. eclipse 集成 STS 插件

    eclipse 集成 STS 插件 想新建一个 Spring Boot 工程,发现没有,如图:(展示的是集成之后的) eclipse 要和 sts 版本对应的,进入http://spring.io/t ...

  5. UVA 212 Use of Hospital Facilities

    题目链接:https://vjudge.net/problem/UVA-212 题意摘自<算法禁赛入门经典> 题目大意 医院里有 N(N ≤ 10)个手术室和 M(M ≤ 30)个恢复室. ...

  6. Cai_Sublime

    Cai_Sublime Package Control:插件包管理工具 The simplest method of installation is through the Sublime Text ...

  7. 17-vim-查找字符或单词-02-查找并替换

    在vi中查找和替换命令需要在末行模式下执行. 命令 功能 :%s///g 末行模式下,查找并替换字符.例:%s /hello/world/g 1.全局替换 一次性替换文件中的所有文件的旧文本. 命令格 ...

  8. CG-CTF pwn部分wp

    面向pwn刷cgctfPWN1,When did you born题目给了一个ELF文件,和一个.C文件先运行ELF,大概如下What’s Your Birth?0What’s Your Name?0 ...

  9. vue--先决篇

    一.vue介绍: vue是一个渐进式Javascript框架. 渐进式:即有一个核心库,在需要的时候,在逐渐添加插件的一种概念. (1)MVVM和MVC模式: MVVM是Model-View-View ...

  10. Javascript高级程序设计--读书笔记之面向对象(二)

    前面讲了面向对象的封装,这章我们就来说一说继承 1.原型链 实现原型链有一种基本模式,其代码大概如下 <script> function SuperType(){ this.propert ...