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

题意:从转发微博的人中抽奖,每n个人抽一次,如果当前人已经中过奖考虑下一个。

坑点:如果序号A已经中过奖,考虑A+1,如果A+1也中过奖,要考虑A+2。。。另外如果A+2没中奖,则A+2中奖,下一次需要从A+2+n再开始遍历。。。(感觉题意不太明确)
 /**
 * Copyright(c)
 * All rights reserved.
 * Author : Mered1th
 * Date : 2019-02-28-13.02.01
 * Description : A1124
 */
 #include<cstdio>
 #include<cstring>
 #include<iostream>
 #include<cmath>
 #include<algorithm>
 #include<string>
 #include<unordered_set>
 #include<map>
 #include<vector>
 #include<set>
 #include<unordered_map>
 using namespace std;
 ;
 string str[maxn];
 unordered_map<string,int> mp;
 int main(){
 #ifdef ONLINE_JUDGE
 #else
     freopen("1.txt", "r", stdin);
 #endif
     int m,n,s;
     bool flag=false;
     scanf("%d%d%d",&m,&n,&s);
     ;i<=m;i++){
         cin>>str[i];
     }
     for(int i=s;i<=m;i=i+n){
         ){
             cout<<str[i]<<endl;
             mp[str[i]]=;
             flag=true;
         }
         else{
             ;j<=m;j++){
                 ){
                     cout<<str[j]<<endl;
                     flag=true;
                     mp[str[j]]=;
                     i=j;
                     break;
                 }
             }
         }
     }
     if(flag==false){
         cout<<"Keep going...";
     }

     ;
 }

1124 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 (20)

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

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

  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. 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. 1124 Raffle for Weibo Followers

    题意:水题,直接贴代码了.(为什么我第一遍做的时候代码写的那么烦?) 代码: #include <iostream> #include <string> #include &l ...

  7. PAT1124:Raffle for Weibo Followers

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

  8. PAT_A1124#Raffle for Weibo Followers

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

  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. django实现api跨域请求访问

    第一步:安装 django-cors-headers pip install django-cors-headers 第二步:配置settings.py文件 --------------------- ...

  2. Go Example--for循环

    package main import "fmt" func main() { i := 1 //Go循环只有for, 第一种循环方式 for i<=3 { fmt.Prin ...

  3. 深入浅出Node.js---Connect模块解析 。转载

    文章地址:https://blog.csdn.net/zhangyuan19880606/article/details/51509205 1 Connect模块背景 Node.js的愿望是成为一个能 ...

  4. openresty redis all in one docker demo

      一个简单的docker demo 集成openresty+ redis,可以实现基于redis的动态修改反向代理的处理 环境准备 docker-compose 文件 version: " ...

  5. 通过script src引入ElementUI时,使用语句:window.ELEMENT.MessageBox.alert(xxx) 调用弹出框

    通过script src引入ElementUI时,使用语句:window.ELEMENT.MessageBox.alert(xxx) 调用弹出框.

  6. re正则匹配使用

    print(result.span()) #输入字符串的范围 如果在匹配语句中有括号,group(1)就是提取第一个括号的内容,以此类推. 扩展思考:如果要从文本中匹配出目标字符串可以使用括号加gro ...

  7. 编写第一个python selenium-webdriver程序(二)

    上节介绍了如何搭建selenium 系统环境,那么本节来讲一下如何开始编写第一个自动化测试脚本. Selenium2.x 将浏览器原生的API封装成WebDriver API,可以直接操作浏览器页面里 ...

  8. java中length与length()

    length是对数组而言的,指的是数组的长度. length()是对字符串而言的,指的是字符串所包含的字符个数. public class LengthDemo { public static voi ...

  9. 配置Hanlp自然语言处理进阶

    中文分词 中文分词中有众多分词工具,如结巴.hanlp.盘古分词器.庖丁解牛分词等:其中庖丁解牛分词仅仅支持java,分词是HanLP最基础的功能,HanLP实现了许多种分词算法,每个分词器都支持特定 ...

  10. kafka_2.11-0.8.2.1生产者producer的Java实现

    转载自:http://blog.csdn.net/ch717828/article/details/50818261 1. 开启Kafka Consumer 首先选择集群的一台机器,打开kafka c ...