PAT_A1124#Raffle for Weibo Followers
Source:
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的更多相关文章
- PAT1124:Raffle for Weibo Followers
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 ...
- 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 ...
- PAT甲级 1124. Raffle for Weibo Followers (20)
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- sublime useful packages
Package control Prefixr Emmet
- 高博SLAM14讲 ch5 点云拼接例程实现与bug处理
一.环境配置,基本库的安装 1.Eigen库 apt-get 安装 2.sophus库 apt-get 安装 3.pcl 点云库 (1)官方预编译版本 sudo apt-get install lib ...
- 基于MFC的Media Player播放器制作的SetTimer函数介绍
| 版权声明:本文为博主原创文章,未经博主允许不得转载. SetTimer是一种API函数,位于user32.dll中.你想每隔一段时间执行一件事的的时候,你可以使用它. 使用定时器的方法比 较简 ...
- os.fork()----linux
fork() 函数,它也属于一个内建并 且只在 Linux 系统下存在. 它非常特殊普通的函数调用,一次返 回但是 fork() 调用一次,返回两次.因为操作系统自动把当前进程(称为父)复制了一份(称 ...
- jmeter 不同线程组之间传递变量3
jemter编写脚本要点: 1.切记:BeanShell PostProcessor写在关联函数 Regular Expression Extractor的后面 2.header HTTP Head ...
- PAT(A) 1042. Shuffling Machine (20)
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
- px2rem-loader(Vue:移动端自适应,px自动转化)
1.下载lib-flexible npm i lib-flexible --save 2.引入lib-flexible import 'lib-flexible/flexible' 3.设置meta标 ...
- v-slot vue2.6新增指令使用指南
子组件 <template> <div class="wrapper"> <slot name="demo" :msg=" ...
- Puppeteer自动化批量上传抖音视频
前言:最近因为项目宣传,所以用Puppeteer写了一个批量上传抖音视频的自动化程序用于推广. 环境和依赖:node,puppeteer 废话不多说,直接上代码: const puppeteer =r ...
- 【知识强化】第五章 输入/输出(I/O)管理 5.2 I/O核心子系统I
学习I/O核心子系统相关的一系列功能. 设备独立性软件.设备驱动程序.中断处理程序这三层其实是属于操作系统的内核部分的,所以它们也称作“I/O核心子系统”,又可以简称为“I/O系统”.在考研当中我们需 ...