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 分)的更多相关文章
- 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 (20)
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- 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[简单]
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
题意:水题,直接贴代码了.(为什么我第一遍做的时候代码写的那么烦?) 代码: #include <iostream> #include <string> #include &l ...
- PAT1124:Raffle for Weibo Followers
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- 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 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 ...
随机推荐
- 【HDOJ1217】【Floyd求最长路】
http://acm.hdu.edu.cn/showproblem.php?pid=1217 Arbitrage Time Limit: 2000/1000 MS (Java/Others) M ...
- How to generate a new dictionary file of mmseg
How to generate a new dictionary file of mmseg 0.Usage about mmseg-node memtioned in github : var mm ...
- LeetCode - Find Duplicate Subtrees
Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only ne ...
- 【HAOI2012】外星人
又犯sb错了QAQ 原题: 艾莉欧在她的被子上发现了一个数字 ,她觉得只要找出最小的x使得,.根据这个 她就能找到曾经绑架她的外星人的线索了.当然,她是不会去算,请你帮助她算出最小的x. test&l ...
- C++编译器报错汇总
1.error: ‘Person’ was not declared in this scope(1)若是一个类或函数的命名空间对使用者不可见(2)成员(静态)函数没有通过对象名或类名进行调用(3)虽 ...
- Linux 性能分析调优 (四)——案例篇:系统中出现大量不可中断进程和僵尸进程怎么办
之前讲到 CPU 使用率的类型.除了上一节提到的用户 CPU 之外,它还包括系统 CPU(比如上下文切换).等待 I/O 的 CPU(比如等待磁盘的响应)以及中断 CPU(包括软中断和硬中断)等. 在 ...
- 深入详解美团点评CAT跨语言服务监控(三)CAT客户端原理
cat客户端部分核心类 message目录下面有消息相关的部分接口 internal目录包含主要的CAT客户端内部实现类: io目录包含建立服务端连接.重连.消息队列监听.上报等io实现类: spi目 ...
- KiCad 5.1.0 正式版终于发布
KiCad 5.1.0 正式版终于发布 前几天看到 KiCad 5.1.0 在官方的测试文件夹中,过了三天正式发布了,看来没什么问题了. 据说比 5.0 快了很多. 以下为官方的新闻. KiCad 5 ...
- 笔记:Python 默认参数必须指向不变对象
笔记:Python 默认参数必须指向不变对象 学习记录 >>> def add_end(L=[]): L.append('END') return L >>> ad ...
- CloudStack学习-3
此次试验主要是CloudStack结合openvswitch 背景介绍 之所以引入openswitch,是因为如果按照之前的方式,一个网桥占用一个vlan,假如一个zone有20个vlan,那么岂不是 ...