题意:微博抽奖,列出follow的人,给出起始点,以及每隔多少人抽一个,抽到重复的依次向后。
思路:模拟即可。
代码
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;
const int MAX_N = 10000;
int M, N, S;
string a[MAX_N];
set<string> st;
bool flag;
int main() {
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
cin >> M >> N >> S;
for (int i = 1; i <= M; i++) cin >> a[i];
int p = S;
flag = false;
while (p <= M) {
while (p <= M && st.count(a[p])) p++;
if (p <= M) {
cout << a[p] << endl;
flag = true;
st.insert(a[p]);
p += N;
}
}
if (!flag) cout << "Keep going..." << endl;
return 0;
}