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 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...
思路
- 需要输出
keep going…
的时候,一定是起始点没有在范围里,只需判断一下起始点的位置特判输出它。 - 接下来就直接按照题意进行编写。比较简单。
code
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
int main(){
int n_user = 0, step = 0, index = 0;
scanf("%d%d%d", &n_user, &step, &index);
vector<string> list(n_user);
unordered_map<string, bool> dic;
for(int i = 0; i < n_user; i++){
list[i].resize(25);
scanf("%s", &list[i][0]);
}
if(index - 1 >= list.size()){
printf("Keep going...");
return 0;
}
for(int i = index - 1; i < list.size(); ){
if(!dic[list[i]]){
dic[list[i]] = true;
printf("%s\n", list[i].c_str());
i += step;
}else i++;
}
return 0;
}
PAT甲级:1124 Raffle for Weibo Followers (20分)的更多相关文章
- PAT甲级 1124. Raffle for Weibo Followers (20)
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- PAT甲级——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 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 (20 分)
1124 Raffle for Weibo Followers (20 分) John got a full mark on PAT. He was so happy that he decided ...
- 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甲级:1136 A Delayed Palindrome (20分)
PAT甲级:1136 A Delayed Palindrome (20分) 题干 Look-and-say sequence is a sequence of integers as the foll ...
- PAT 甲级 1054 The Dominant Color (20 分)
1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ab ...
- PAT 甲级 1027 Colors in Mars (20 分)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...
随机推荐
- python小知识,列表推导式
使用列表推导式可以快速生成一个列表,或者根据某个列表生成满足指定需求的列表. 1.生成指定范围的数值列表,语法格式如下: list=[Expression for var in range if co ...
- 重新整理 .net core 实践篇—————日志系统之结构化[十八]
前言 什么是结构化呢? 结构化,就是将原本没有规律的东西进行有规律话. 就比如我们学习数据结构,需要学习排序然后又要学习查询,说白了这就是一套,没有排序,谈如何查询是没有意义的,因为查询算法就是根据某 ...
- MindSpore自定义模型损失函数
技术背景 损失函数是机器学习中直接决定训练结果好坏的一个模块,该函数用于定义计算出来的结果或者是神经网络给出的推测结论与正确结果的偏差程度,偏差的越多,就表明对应的参数越差.而损失函数的另一个重要性在 ...
- es6 快速入门 系列 —— promise
其他章节请看: es6 快速入门 系列 Promise Promise 是一种异步编程的选择 初步认识Promise 用 Promise 来实现这样一个功能:发送一个 ajax,返回后输出 json ...
- 如何回答面试中问到的Hibernate和MyBatis的区别
这边主要是写给那些准备去面试的(没什么经验的)应聘者看的,为了在面试中更好的回答这个问题,我做一个简单的梳理和总结. 作为一名职场新人,经历过多次的面试,由于在简历中提及了Hibernate和MyBa ...
- centos7安装JDK、CentOS
1.安装JDK 1.1查看系统是否已有自带的JDK rpm -qa |grep java rpm -qa |grep jdk rpm -qa |grep gcj 1.2卸载已有安装 如果没有输出信息, ...
- 利用 V8 深入理解 JavaScript 设计
JavaScript 代码运行 以大家开发常用的 chrome 浏览器或 Node 举例,我们的 JavaScript 代码是通过 V8 运行的.但 V8 是怎么执行代码的呢?当我们输入 const ...
- python用random模块模拟抽奖逻辑(print修改end参数使打印结果不分行)
import random #引入random模块,运用random函数list_one=["10081","10082","10083" ...
- 什么是Mirai僵尸网络
1.什么是Mirai? Mirai是恶意软件,能够感染在ARC处理器上运行的智能设备,将其转变为远程控制的机器人或"僵尸"并组成网络.这种机器人网络称为僵尸网络,通常用于发动DDo ...
- linux 查看目录大小
查看当前目录下各个目录大小容量 du -sh * du -sh /app/* du -h --max-depth=1 .