-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBJAlgo_1158.java
More file actions
31 lines (25 loc) · 932 Bytes
/
Copy pathBJAlgo_1158.java
File metadata and controls
31 lines (25 loc) · 932 Bytes
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
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class BJAlgo_1158 {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] NK = br.readLine().split(" ");
int N = Integer.parseInt(NK[0]);
int K = Integer.parseInt(NK[1]);
List memberList = new ArrayList();
List result = new ArrayList();
int popNum = 0;
for(int i = 0; i < N; i++) {
memberList.add(i + 1);
}
while (memberList.size() > 0) {
popNum = (popNum + (K - 1)) % memberList.size();
String data = String.valueOf(memberList.get(popNum));
memberList.remove(popNum);
result.add(data);
}
System.out.println("<" + String.join(", ", result) + ">");
}
}