智算之道初赛第一场-排队
程序员文章站
2022-03-09 16:05:56
...
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(); //总人数
int m = sc.nextInt(); //窗口数
int[] a = new int[m]; //定义一个数组存储每个窗口的a[i]
int count = n; //剩余人数
for (int i = 0; i < a.length; i++) {
a[i] = sc.nextInt();
}
for (int i = 1; i <= n; i++) {
for (int j = 0; j < a.length; j++) {
if(i % a[j] == 0){
count--;
break;
}
}
}
System.out.println(count);
}
}