博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PAT甲级——A1124 Raffle for Weibo Followers
阅读量:4541 次
发布时间:2019-06-08

本文共 2059 字,大约阅读时间需要 6 分钟。

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 2Imgonnawin!PickMePickMeMeMeeeLookHereImgonnawin!TryAgainAgainTryAgainAgainImgonnawin!TryAgainAgain

Sample Output 1:

PickMeImgonnawin!TryAgainAgain

Sample Input 2:

2 3 5Imgonnawin!PickMe

Sample Output 2:

Keep going...
1 #include 
2 #include
3 #include
4 using namespace std; 5 int m, k, s; 6 int main() 7 { 8 cin >> m >> k >> s; 9 unordered_map
res;10 string str;11 for (int i = 1; i <= m; ++i)12 {13 cin >> str;14 if (i == s)15 {16 if (res[str] == 1)//输出过17 s++;//后移动18 else19 {20 cout << str << endl;21 res[str] = 1;22 s += k;23 }24 }25 }26 if (res.size() == 0)27 cout << "Keep going..." << endl;28 return 0;29 }

 

转载于:https://www.cnblogs.com/zzw1024/p/11477921.html

你可能感兴趣的文章
mybatis2入门程序
查看>>
解决html设置height:100%无效的问题
查看>>
ECMAScript 5 中的数组方法
查看>>
SpringBoot整合StringData JPA
查看>>
tensorflow conv2d
查看>>
课堂练习
查看>>
如何使VS2008 调试网站的根目录和IIS调试的一致?
查看>>
Apple 企业开发者账号&邓白氏码申请记录
查看>>
[bzoj5457]城市_dsu on tree
查看>>
[计蒜客T2237]魔法_树
查看>>
2018.10.19 NOIP训练 游戏问题(分组背包)
查看>>
01背包
查看>>
一道面试题关于js中添加动态属性
查看>>
结对编程项目——四则运算
查看>>
XML分页
查看>>
input、raw_input区别,运算符,运算优先级,多变赋值方式
查看>>
grpc python quickstart
查看>>
oracle异常处理
查看>>
scrapy下载中间件,UA池和代理池
查看>>
NOIP2017 宝藏 题解报告【状压dp】
查看>>