PAT1124:Raffle for Weibo Followers
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... 思路 1.map模拟一个字典dic记录该用户是否领过奖。2.用一个bool值hasWinner来标记是否有人获过奖。 代码
#include<iostream> #include<vector> #include<map> using namespace std; int main() {int M,N,S;while(cin >> M >> N >> S){vector<string> List(M + 1);map<string,int> dic;bool hasWinner = false;for(int i = 1;i <= M;i++){cin >> List[i];}for(int i = S;i <= M;i += N){while(dic.count(List[i]) > 0 && i <= M) i++;if(i > M) break;hasWinner = true;cout << List[i] << endl;dic[List[i]]++;}if(!hasWinner)cout << "Keep going..." << endl;} }
转载于:https://www.cnblogs.com/0kk470/p/7739808.html
PAT1124:Raffle for Weibo Followers相关推荐
- PAT-1124. Raffle for Weibo Followers (20)
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- 【PAT (Advanced Level) Practice】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 :[C++题解]哈希表、微博转发抽奖
文章目录 题目分析 题目来源 题目分析 来源:acwing 分析:开一个哈希表存已经中将的用户,避免重复发奖. 遍历所有m条姓名,从第一个中奖的开始,依次模拟即可. ac代码 #include< ...
- PAT 1124 Raffle for Weibo Followers python解法
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
PAT 1124 Raffle for Weibo Followers Java 1.题意 输入:数字m,n,s,一串人名. 第s个为获奖的人,则s+n 为下一个获奖的人,如果此人已经获奖,那么则往后 ...
- 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_A 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 ...
- 【PAT1124】Raffle for Weibo Followers
1. 题目 2. 代码 #include <iostream> #include <unordered_map> #include <cstring> using ...
- 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 ...
最新文章
- 修复 Windows XP/2003 双系统无法启动
- php依次替换文本字符串中的图片src地址
- 【Windows 逆向】使用 CE 工具挖掘关键数据内存真实地址 ( 逐层分析分析 静态地址 到 动态地址 的寻址 + 偏移 过程 ) ★
- 传统的http请求存在那些缺点
- Algorithm:C++语言实现之SimHash和倒排索引算法相关(抽屉原理、倒排索、建立查找树、处理Hash冲突、Hash查找)
- Android中实现不同文字颜色和图文混排的Span总结
- (巴什博弈 sg函数入门1) Brave Game -- hdu -- 1846
- 通俗易懂,一篇文章告诉你编程语言是个啥?
- 为Angular(2+)开发人员提供带TypeScript的Vue.js
- win7打补丁显示不适用计算机,更新win7系统提示“此更新不适用于您的计算机”如何解决...
- 电话号码大全(常识版)
- geforce experience出现错误尝试重启PC
- php agrs zf2,添加ZF2_PATH environment variable 环境变量
- 麒麟信安邀您抢先看 | openEuler 志高远,开源汇智创未来-开放原子全球开源峰会欧拉分论坛最详细议程出炉
- pyecharts源码解读(10)渲染包render之templates目录:渲染模板
- 你见过哪些好用到爆的 Java 代码技巧?
- Twitter网站架构介绍(转)
- c语言成绩管理系统常见错误,求教 学生成绩管理系统出错
- 字体包压缩-字体包抽取
- 关于参加计算机培训的通讯报道,通讯员积极参加新闻宣传培训班
热门文章
- 第十四篇 元类编程(二)
- 一加6手机突然没信号没服务器,如何从技术上解决手机信号问题?一加6替你想到了...
- allow php tag,Smarty allow_php_tag报告'未定义的属性:Smarty :: $ allow_php_tag'
- python 命令行解析模块_Python解析命令行读取参数 -- argparse模块
- Spark源码分析之Master状态改变处理机制原理
- (190)FPGA变量初始化方法initial
- (150)System Verilog仿真结束机制
- (07)VHDL实现闪灯
- 计算机系统设计 片上系统 pdf,一种基于过程级编程模型的可重构片上系统设计方法.pdf...
- php中is null,php中empty(), is_null(), isset()函数区别