星空's Blog
PAT-A1124 Raffle for Weibo Followers

原题

Raffle for Weibo Followers (20 分)

题解

微博抽奖哈哈

代码

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(void) {
    vector<string> lucky;
    int m,n,s;
    cin >> m >> n >> s;
    string forward[m + 1];
    for (int i = 1;i <= m;i++) {
        cin >> forward[i];
    }
    if (m < s) {
        cout << "Keep going..." << endl;
        return 0;
    }
    for (int i = s;i <= m;) {
        if (count(lucky.begin(),lucky.end(),forward[i])) {
            i++;
            continue;
        }
        lucky.push_back(forward[i]);
        cout << forward[i] << endl;
        i += n;
    }
    return 0;
}
博客所有文章禁止转载。
算法AC代码仅供参考,请不要未经修改直接套用。
首页      算法学习      PAT-A      PAT-A1124 Raffle for Weibo Followers
https://secure.gravatar.com/avatar/271861a23dcdde929d3ee8cb8c04f854?s=256&d=monsterid&r=g

星空

文章作者

发表评论

textsms
account_circle
email

星空's Blog

PAT-A1124 Raffle for Weibo Followers
原题 Raffle for Weibo Followers (20 分) 题解 微博抽奖哈哈 代码 #include <iostream> #include <vector> #include <string> #include <algorithm> using name…
扫描二维码继续阅读
2019-09-01
分类
标签云