Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class S1 {
- static int[] a;
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- int a1 = s.nextInt();
- a = new int[a1];
- int a2 = s.nextInt();
- for(int i = 0; i < a.length; i++)
- a[i] = i + 1;
- for(int i = 0; i < a2; i++) {
- int r = s.nextInt();
- for(int j = 1; j <= a.length; j++) {
- if(j % r == 0) a[j-1] = 0;
- }
- reset();
- }
- print();
- }
- static void print() {
- for(int a : a) {
- if(a != 0) System.out.println(a);
- }
- }
- static void reset() {
- for(int i =0; i < a.length; i++) {
- if(a[i] == 0) {
- for(int j = i; j < a.length - 1; j++) {
- a[j] = a[j+1];
- }
- a[a.length - 1] = 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement