“人其实就这一辈子,我想要的生活不是安逸的,虽然很累,但我想要辉煌的人生,所以也一直在为此努力、不松懈。我所理解的辉煌人生,不是挣了多少钱、做了多伟大的事,而是将人生过得有意义,不碌碌无为。哪怕前进得很慢,但是每分每秒都在往前走,去追求梦想。” ----喻言
小明 PAT 考了满分,高兴之余决定发起微博转发抽奖活动,从转发的网友中按顺序每隔 N 个人就发出一个红包。请你编写程序帮助他确定中奖名单。
输入格式:
输入第一行给出三个正整数 M(≤ 1000)、N 和 S,分别是转发的总量、小明决定的中奖间隔、以及第一位中奖者的序号(编号从 1 开始)。随后 M 行,顺序给出转发微博的网友的昵称(不超过 20 个字符、不包含空格回车的非空字符串)。
注意:可能有人转发多次,但不能中奖多次。所以如果处于当前中奖位置的网友已经中过奖,则跳过他顺次取下一位。
输出格式:
按照输入的顺序输出中奖名单,每个昵称占一行。如果没有人中奖,则输出 Keep going...
。
输入样例 1:
9 3 2
Imgonnawin!
PickMe
PickMeMeMeee
LookHere
Imgonnawin!
TryAgainAgain
TryAgainAgain
Imgonnawin!
TryAgainAgain
输出样例 1:
PickMe
Imgonnawin!
TryAgainAgain
输入样例 2:
2 3 5
Imgonnawin!
PickMe
输出样例 2:
Keep going...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#include <numeric>
#include<unordered_set>
#include <climits>//INT_100010n
//#include<bits/stdc++.h>
#define PP pair<ll,int>
#define inf 0x3f3f3f3f
#define INF 0x7fffffff;
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
#define PI 3.1415926
#define LL unsigned int
#define mod 1000000007
#define wc 1e-18
typedef long long ll;
using namespace std;
int m, n, s, fg;
string str;
map<string, int> mp;
int main()
{
scanf("%d%d%d", &m, &n, &s);
for (int i = 1; i <= m; i++)
{
cin >> str;
if (mp[str] == 1)
s = s + 1;
if (i == s && mp[str] == 0)
{
mp[str] = 1;
cout << str << endl;
fg = 1;
s = s + n;
}
}
if (fg == 0)
cout << "Keep going...";
return 0;
}