-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCCC14S1.java
More file actions
58 lines (56 loc) · 1.04 KB
/
CCC14S1.java
File metadata and controls
58 lines (56 loc) · 1.04 KB
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
52
53
54
55
56
57
58
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int k = in.nextInt();
int m = in.nextInt();
int[] x = new int[m];
int[] y = new int[k];
int i = 0;
int g = 0;
int j = 0;
while(i<m){
x[i]=in.nextInt();
i++;
}
i=0;
while(i<k){
y[i]=i+1;
i++;
}
i=0;
int n = 0;
while(g<m){
while(i<k){
if((i+1)%x[g]==0){
y[i]=0;
}
i++;
}
i=0;
while(i<k){
if(y[i]==0){//COMPACTING
j=i;
while(j<k){
if(j<=k-2){
y[j]=y[j+1];
}
j++;
}
}
i++;
}
i=0;
g++;
}
System.out.println(y[0]);
i=1;
while(i<k){
if(y[i]!=y[i-1]&&y[i]!=0){
System.out.println(y[i]);
}
i++;
}
}
}