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 ...
随机推荐
- 《一头扎进》系列之Python+Selenium框架实战篇7 - 年底升职加薪,年终奖全靠它!Merry Christmas
1. 简介 截止到上一篇文章为止,框架基本完全搭建完成.那么今天我们要做什么呢????聪明如你的小伙伴或者是童鞋一定已经猜到了,都测试完了,当然是要生成一份高端大气上档次的测试报告了.没错的,今天宏哥 ...
- 用 Flask 来写个轻博客 (8) — (M)VC_Alembic 管理数据库结构的升级和降级
Blog 项目源码:https://github.com/JmilkFan/JmilkFan-s-Blog 目录 目录 前文列表 扩展阅读 Alembic 查看指令 manager db 的可用选项 ...
- OAccflow集成sql
SELECT * FROM PORT_EMP WHERE NO='18336309966'SELECT * FROM PORT_DEPT WHERE no='42DBAF50712C4046B09BC ...
- Eclipse转idea改设置
1 自动导包:画圈的打钩,实现自动导包,去除无用包.导入的类名相同时需要自己手动导包-> alt+enter. 2:修改快捷键 左移光标,右移同理. 上移光标:下移同理 光标移至行首,行末为e ...
- [转]关于Unity中文件读取 - 大世界
原文 http://www.cnblogs.com/ThreeThousandBigWorld/p/3199245.html 存储: 在程序发布后文件的存放有两种,第一种是打包到Uniyt的资源包 ...
- pat甲级题目1001 A+B Format详解
pat1001 A+B Format (20 分) Calculate a+b and output the sum in standard format -- that is, the digits ...
- 力扣算法——133.CloneGraph【M】
Given a reference of a node in a connected undirected graph, return a deep copy (clone) of the graph ...
- Apache—httpd服务创建个人用户主页功能
创建个人用户主页功能 第1步:开启个人用户主页功能 UserDir disabled前加# UserDir public_html 去掉前面# UserDir参数表示的是需要在用户家目录中创建的网站 ...
- Puppeteer自动化测试cnode.js中文社区
如果完全不了解puppeteer的朋友可以去看看我的这篇随笔:https://www.cnblogs.com/zlforever-young/p/11569890.html 开始之前需要了解的知识:E ...
- Mysql差集
记录一个去差集的SQL 今天用sql去同步部分历史数据,需要用到一个求差集的sql 两张表简单结构如下: 有一个会员表 一个会员账户表 获取没有账户的会员 SELECT m.pkMember FROM ...