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 ...
随机推荐
- 20165313 《Java程序设计》第七周学习总结
教材学习总结 1.下载安装MySQL数据库管理系统. 2.MySQL数据库基本操作. 3.利用JAVA程序对MySQL数据库系统进行查找,更新,添加和删除操作. 学习中的问题与解决方案 1.运行书上安 ...
- 欢迎大家使用Druid,常见问题在这里解答,希望对大家有所帮助
https://github.com/alibaba/druid/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 欢迎大家使用Druid,常见问题在这里解答,希望对 ...
- 计算字符串最后一个单词的长度,单词以空格隔开。 java算法
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner in = ne ...
- Vue 1组件的使用
在components新建一个vue组件: <template> <div> <h1>{{ msg }}</h1> </div> </ ...
- CH4908 Race
题意 4908 Race 0x49「数据结构进阶」练习 描述 给定一棵 N 个节点的树,每条边带有一个权值. 求一条简单路径,路径上各条边的权值和等于K,且路径包含的边的数量最少. 输入格式 第一行两 ...
- shell dict 操作
shell 读取文件,利用dict 合并第一列 . #!/bin/bash result_file="a" declare -A mydict total=`cat ${resul ...
- Unity API 解析 (陈泉宏著)
1 Application类 2 Camera类 3 GameObject类 4 HideFlags类 5 Mathf类 6 Matrix4x4类 7 Object类 8 Quaternion类 9 ...
- 非递归和递归分别实现求第n个斐波那契数。
菲波那切数列为:0 1 1 2 3 5 8 13 21 34... 规律:从第三个数字起后面的每一个数字都是前两个数字的和. 非递归算法: #include<stdio.h> int ma ...
- MongoDB journal与oplog解惑
journal journal 是 MongoDB 存储引擎层的概念,目前 MongoDB主要支持 mmapv1.wiredtiger.mongorocks 等存储引擎,都支持配置journal. M ...
- 127.0.0.1 localhost 0.0.0.0 回环地址区别
127.0.0.1:一般认为是本机ip,这个没错.但是本机ip不只是 127.0.0.1 而是所有回环地址. 回环地址: 包括127.0.0.1在内的 所有 指向本机的地址.范围是 127.0.0. ...