PAT 1124

题目 : Raffle for Weibo Followers

分值 : 20
难度 : 水题
思路 : 贼简单
坑点 : 貌似没有

具体代码如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <map>
using namespace std;
string data[1001] ;
map <string,int> Map ;
int main() {
int M ,N ,S ;
cin >> M >> N >>S ;
for(int i = 0 ; i< M ; i++)
cin >> data[i+1] ;
if(M<S) {
cout<<"Keep going..."<<endl ;
return 0 ;
}
for(int i = S ; i<=M ; i+=N)
{
string now = data[i] ;
if(Map[now] == 0 )
{
cout <<now<<endl ;
Map[now] =1 ;
}
else
{
while(Map[data[i]]!=0 && i <=M )
{
i++ ;
}
cout << data[i]<<endl ;
}
}


}