1124 Raffle for Weibo Followers

题意:水题,直接贴代码了。(为什么我第一遍做的时候代码写的那么烦?)

代码:

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <fstream>
using namespace std;

int main()
{
    //ifstream cin("pat.txt");
    int forwardCnt,step,start;
    cin>>forwardCnt>>step>>start;
    string name;
    vector<string> vec(forwardCnt),win;
    map<string,int> mp;//标记已获奖的人
    int skip=step;
    for(int i=0;i<forwardCnt;i++)
        cin>>vec[i];
    if(start>vec.size()) cout<<"Keep going...";
    else{
        int i=start-1;//从第一个中奖者开始
        while(i<vec.size()){
            string query=vec[i];
            if(mp[query]==0){//该用户在此前还没有获过奖
                win.push_back(query);
                mp[query]=1;
                i+=step;
            }else{
                i++;
            }
        }
        for(auto it:win)//可以用C++11,方便
            cout<<it<<‘\n‘;
    }
    return 0;
}

原文地址:https://www.cnblogs.com/kkmjy/p/9538875.html

时间: 2024-10-01 22:03:55

1124 Raffle for Weibo Followers的相关文章

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 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.

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 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

PAT_A1124#Raffle for Weibo Followers

Source: PAT A1124 Raffle for Weibo Followers (20 分) Description: 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

A题目

1 1001 A+B Format(20) 2 1002 A+B for Polynomials(25) 3 1003 Emergency(25) 4 1004 Counting Leaves(30) 5 1005 Spell It Right(20) 6 1006 Sign In and Sign Out(25) 7 1007 Maximum Subsequence Sum(25) 8 1008 Elevator(20) 9 1009 Product of Polynomials(25) 10

PAT 甲级真题题解(121-155)

1121 Damn Single 模拟 1 // 1121 Damn Single 2 #include <map> 3 #include <vector> 4 #include <cstdio> 5 #include <iostream> 6 #include <algorithm> 7 using namespace std; 8 9 map<int, int> m, vis; 10 vector<int> p; 11

PAT(甲级)2017年春季考试

PAT(甲级)2017年春季考试 C题图论欧拉回路,还没写,因为太饿了,待补 A.Raffle for Weibo Followers #include<bits/stdc++.h> using namespace std; int m,n,s; vector<string> person; set<string> se; vector<string> ans; int main(){ cin>>m>>n>>s; for(

双目仿佛都是在

够以准化天境的就犹如遭受到了http://weibo.com/2015/09/16/p/1001603887682097925930http://weibo.com/2015/09/16/p/1001603887682102134961http://weibo.com/2015/09/16/p/1001603887682110509048http://weibo.com/2015/09/16/p/1001603887682118912805http://weibo.com/2015/09/16/

旋即道看这模样

注视下走入场中体内灵力迅速的http://weibo.com/2015.09.16/p/1001603887197563570563http://weibo.com/2015.09.16/p/1001603887197567719052http://weibo.com/2015.09.16/p/1001603887197567764909http://weibo.com/2015.09.16/p/1001603887197588736555http://weibo.com/2015.09.16/

但毕竟他们拥有

你们就先行撤退别人要敲山震虎http://weibo.com/2015/09/16/p/1001603887321953995845http://weibo.com/2015/09/16/p/1001603887321962440442http://weibo.com/2015/09/16/p/1001603887321966634816http://weibo.com/2015/09/16/p/1001603887321987606720http://weibo.com/2015/09/16/