-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPartyInvitation.java
More file actions
35 lines (30 loc) · 898 Bytes
/
PartyInvitation.java
File metadata and controls
35 lines (30 loc) · 898 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
32
33
34
35
import java.io.*;
import java.util.*;
public class PartyInvitation
{
public static void main(String[] args) throws IOException
{
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
int k = Integer.parseInt(b.readLine());
int m = Integer.parseInt(b.readLine());
ArrayList<Integer> list = new ArrayList<Integer>();
for(int i = 1;i<=k;i++)
{list.add(i);}
for(int i = 0; i<m; i++)
{
int number = Integer.parseInt(b.readLine());
Iterator it = list.iterator();
int index = 1;
while(it.hasNext())
{
int j = (int)it.next();
if(index%number == 0) it.remove();
index++;
}
}
for(int i: list)
{
System.out.println(i);
}
}
}