[SWEA] 알 덴테 스파게티

문제 보러가기

제한사항

이외의 제한사항은 없다.

Code

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
import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int tc=1;tc<=T;tc++ ) {
			int N = sc.nextInt();
			int B = sc.nextInt();
			int E = sc.nextInt();
			int[] x = new int[N];
			for(int i=0; i<N; i++) {
				x[i] = sc.nextInt();
			}
			int ans = 0;
			for(int j=0; j<N; j++ ) {
				for(int i=B-E; i<=B+E; i++) {
					if ( i%x[j] == 0 ) {
						ans++;
						break;
					}
				}
			}
			System.out.println("#"+tc+" "+ans);
		}
	}
}