-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathI069.java
51 lines (49 loc) · 1.57 KB
/
I069.java
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package levelB;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class I069 {
public static void main(String[] args) throws Exception{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String[] str=br.readLine().split(" ");
int M=Integer.parseInt(str[0]); //转发总量
int N=Integer.parseInt(str[1]); //中奖间隔
int S=Integer.parseInt(str[2]); //第一位中奖者编号
String[] trans=new String[M];
for(int i=0;i<trans.length;i++){
trans[i]=br.readLine();
}
br.close();
ArrayList<String> list=new ArrayList<>();
if(trans.length>=S){
list.add(trans[S-1]);
}else{
System.out.print("Keep going...");
System.exit(1);
}
for(int i=S+N-1;i<trans.length;){
boolean flag=true;
for(int j=0;j<list.size();j++){
if(trans[i].equals(list.get(j))){
flag=false;
i++;
break;
}
}
if(flag==true){
list.add(trans[i]);
i+=N;
}
}
if(list.size()==0){
System.out.print("Keep going...");
}else{
for(int i=0;i<list.size();i++){
System.out.print(list.get(i));
if(i!=list.size()-1){
System.out.println();
}
}
}
}
}