-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAlex_Goes_Shopping.java
More file actions
34 lines (32 loc) · 927 Bytes
/
Alex_Goes_Shopping.java
File metadata and controls
34 lines (32 loc) · 927 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
import java.util.Scanner;
public class Alex_Goes_Shopping {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int arr[]=new int[n];
for (int i = 0; i < n ; i++) {
arr[i]=s.nextInt();
}
int q=s.nextInt();
int que[]=new int[q];
int que1[]=new int[q];
for (int i = 0; i < q; i++) {
que[i]=s.nextInt();
que1[i]=s.nextInt();
}
int count=0;
for (int i = 0; i < q; i++) {
count=0;
for (int j = 0; j <n ; j++) {
if(que[i]>que1[j] && que[i]%arr[j]==0){
count++;
}
}
if(count==que1[i]){
System.out.println("Yes");
}
else
System.out.println("No");
}
}
}