-
Notifications
You must be signed in to change notification settings - Fork 3
/
CCC14S1.java
38 lines (37 loc) · 1.2 KB
/
CCC14S1.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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
/**
* CCC '14 S1 - Party Invitation
* Question type: Implementation
* 250/250 on DMOJ
* Question URL: https://dmoj.ca/problem/ccc14s1
* @author Tommy Pang
*/
public class CCC14S1 {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;
public static void main(String[] args) throws IOException {
List<Integer> list1 = new ArrayList<>();
List<Integer> list2 = new ArrayList<>();
int N = Integer.parseInt(br.readLine());
for (int i = 1; i <= N; i++) {
list1.add(i);
}
int M = Integer.parseInt(br.readLine());
for (int i = 0; i < M; i++) {
int a = Integer.parseInt(br.readLine());
for (int j = 1; j <= list1.size(); j++) {
if (!(j%a==0)) list2.add(list1.get(j-1));
}
list1=list2;
list2 = new ArrayList<>();
}
for (int nxt : list1) {
System.out.println(nxt);
}
}
}