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 ...
随机推荐
- MEMS传感器作为变革的驱动力
MEMS sensors as drivers for change 物联网(IoT)正在改变与周围世界互动的方式.每个人,每件事,都是相互联系的,很快就会相互联系.微机电系统(MEMS)设备和传感器 ...
- Java设计模式(4:里氏替换原则和合成复用原则详解
一.里氏替换原则 如果说实现开闭原则的关键步骤就是抽象化,那么基类(父类)和子类的继承关系就是抽象化的具体实现,所以里氏替换原则就是对实现抽象化的具体步骤的规范.即:子类可以扩展基类(父类)的功能,但 ...
- python应用_异常处理
我们把可能发生错误的语句放在try模块里,用except来处理异常. 参考学习链接: https://www.cnblogs.com/OliverQin/p/12222619.html 异常处理的完整 ...
- 【逆向&渗透实战】Dump内存中的Dex_我是如何脱壳某公司加固过的Apk并利用其API渗透对方数据库
/作者:Kali_MG1937 QQ:3496925334 CNBLOG博客号:ALDYS4/ 某天午睡,朦朦胧胧梦到给学校提供建站模板的公司有个注射点 梦醒后,我凭借着零散的记忆日进了对面的数据库, ...
- 【工具解析】瑞士军刀bettercap2.X_解析_第二期_内网钓鱼(嗅探)工具编写
/文章作者:Kali_MG1937 CNBLOG博客:ALDYS4 QQ:3496925334/ 第一期: https://www.cnblogs.com/aldys4/p/14877783.html ...
- UF_CLONE 克隆操作
Open C UF_CLONE_add_assembly 添加装配到克隆操作UF_CLONE_add_part 添加部件到克隆操作UF_CLONE_apply_defaultsU ...
- Django(68)drf分页器的使用
前言 当后台返回的数据过多时,我们就要配置分页器,比如一页最多只能展示10条等等,drf中默认配置了3个分页面 PageNumberPagination:基础分页器,性能略差 LimitOffsetP ...
- Linux常用目录解释
FHS:Linux /boot:系统启动相关的文件,如内核,initrd,以及grub(bootloader) /dev :设备文件: 块设备:随机访问,数据块 字符设备,线性访问,按字符为单位 设备 ...
- Golang限制函数调用次数
Golang限制函数调用次数 项目环境 ubuntu+go1.14 需求描述 限制某个函数5秒内只能调用一次,5秒内的其他调用抛弃 工具包使用 这里用到了官方限流器/time/rate 该限流器是基于 ...
- [HTML]常用的文本标签(标题、段落、加粗、下划线等标签)
标签类型 写法 说明 标题 <h1></h1>......<h6></h6> 加粗.独占一行(块级元素) 段落 <p></p> ...