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 ...
随机推荐
- 如何为应用选择最佳的FPGA(上)
如何为应用选择最佳的FPGA(上) How To Select The Best FPGA For Your Application 在项目规划阶段,为任何一个项目选择一个FPGA部件是最关键的决策之 ...
- jmeter工作目录介绍、jmeter元件及组件介绍
一.jmeter工作目录介绍: bin:放置各项配置文件(如日志设置.JVM设置).启动文件.启动Jar包.示例脚本等: docs:放置JMeter API的离线帮助文档: extras:JMeter ...
- KIP-5:Apache Kylin深度集成Hudi
Q1. What are you trying to do? Articulate your objectives using absolutely no jargon. Q2. What probl ...
- 【NX二次开发】常用的标准对话框
1.uc1601 单按钮模态对话框 1 //来自"王牌飞行员_里海"的测试源码(qq群753801561) 2 extern DllExport void ufusr(char * ...
- 重磅!GitHub官方开源新命令行工具
近日,GitHub 发布命令列工具 (Beta) 测试版,官方表示,GitHub CLI提供了一种更简单.更无缝的方法来使用Github.这个命令行工具叫做GitHub CLI,别名gh. 现在,你就 ...
- 谷歌浏览器加载驱动(chromedriver)——selenium
http://chromedriver.storage.googleapis.com/index.html 可以到该网站下载对应的谷歌驱动器(注意:需要版本和操作系统对应,其中windows统一32的 ...
- C# 设置Word文本框中的文字旋转方向
在Word中可插入文本框,默认情况下插入的文本框中的文字方向为横向排列,对于一些特殊文档的设计要求,需要改变文字方向,如本次测试中的文档排版为考生试卷类型,考生信息栏的内容为下图中的这种, 本文将以C ...
- Java8新特性代码示例(附注释)- 方法引用,Optional, Stream
/** * java8中的函数式接口,java中规定:函数式接口必须只有一个抽象方法,可以有多个非抽象方法,同时,如果继承实现了 * Object中的方法,那么也是合法的 * <p> * ...
- 38、mysql数据库(pymysql及事务)
38.1.python之pymysql模块: 1.说明: pymsql是Python中操作MySQL的模块,其使用方法和py2的MySQLdb几乎相同. 2.模块安装: pip install pym ...
- VSCode 使用 Code Runner 插件无法编译运行文件名带空格的文件
本文同时在我的博客发布:VSCode 使用 Code Runner 插件无法编译运行文件名带空格的文件 - Skykguj 's Blog (sky390.cn) 使用 Visual Studio C ...