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 sum()函数的用法
sum() 方法对系列进行求和计算.针对元组,列表.对字符串会报错 >>>sum([0,1,2]) 3 >>> sum((2, 3, 4), 1) # 元组计算总和 ...
- MacBook Pro常用快捷键
MacBook Pro常用快捷键 Mac fn + left / right / up / down 相当于 home/end/page up /page down delete 删除光标前一个字符 ...
- 68、Schema的相关类
public class SObjectSchema { public void testSchema(){ //获取SObject的token //1.先获取所有token,然后通过key获取需要的 ...
- PAT_A1100#Mars Numbers
Source: PAT A1100 Mars Numbers (20 分) Description: People on Mars count their numbers with base 13: ...
- nginx -stream(tcp连接)反向代理配置 实现代理mysql以及文件上传
原文链接:https://blog.csdn.net/Activity_Time/article/details/95767390 1. stream模块安装 nginx默认安装的时候无法加载流str ...
- CSRF如何防御
总结网上所说,细细的归纳下 CSRF利用的时网站对用户网页浏览器的信任.在受害人不知情的情况下以 受害人的名义伪造请求发送给攻击者的站点. 1.首先XSS漏洞先防护好(一般是通过过滤器更改特殊字符) ...
- PHP数组循环遍历的几种方式
PHP数组循环遍历 1.for循环 <?php //语法 for (init counter; test counter; increment counter) { code to be exe ...
- 推荐一款 MyBatis 开发神器,为简化而生!
Java技术栈 )); MyBatis-Plus将会生成以下查询SQL: SELECT * FROM user WHERE age >= 18FROM user WHERE age >= ...
- iView + vue-quill-editor 实现一个富文本编辑器(包含图片,视频上传)
1. 引入插件(注意IE10以下不支持) npm install vue-quill-editor --savenpm install quill --save (Vue-Quill-Editor需要 ...
- 案例-2D会旋转的盒子(rotate), 会缩放的盒子(scale),动画(animation)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...