Integral Array

시간 제한2초메모리 제한1024 MB

요약
양의 정수 배열이 주어질 때, 임의의 두 원소 x, y(x≥y)에 대해 x를 y로 나눈 몫의 내림값도 배열 안에 존재하는지 판정한다. n의 합은 10^6, c의 합은 10^7까지 커질 수 있다.
난이도

어려움10점 중 8점

유형
수학, 정수론, 완전 탐색, 누적 합
정답자
아직 제출이 없습니다

문제

You are given an array aa of nn positive integers numbered from 11 to nn. Let's call an array integral if for any two, not necessarily different, numbers xx and yy from this array, x≥yx \ge y, the number ⌊xy⌋\left \lfloor \frac{x}{y} \right \rfloor (xx divided by yy with rounding down) is also in this array.

You are guaranteed that all numbers in aa do not exceed cc. Your task is to check whether this array is integral.

입력

The input consists of multiple test cases. The first line contains a single integer tt (1≤t≤10,0001 \le t \le 10\\,000) --- the number of test cases. Description of the test cases follows.

The first line of each test case contains two integers nn and cc (1≤n≤1061 \le n \le 10^6, 1≤c≤1071 \le c \le 10^7) --- the size of aa and the limit for the numbers in the array.

The second line of each test case contains nn integers a_1a\_1, a_2a\_2, …\ldots, a_na\_n (1≤a_i≤c1 \le a\_i \le c) --- the array aa.

Let NN be the sum of nn over all test cases and CC be the sum of cc over all test cases. It is guaranteed that N≤106N \le 10^6 and C≤107C \le 10^7.

출력

For each test case print Yes if the array is integral and No otherwise.

힌트

In the first test case it is easy to see that the array is integral:

  • ⌊11⌋=1\left \lfloor \frac{1}{1} \right \rfloor = 1, a_1=1a\_1 = 1, this number occurs in the arry
  • ⌊22⌋=1\left \lfloor \frac{2}{2} \right \rfloor = 1
  • ⌊55⌋=1\left \lfloor \frac{5}{5} \right \rfloor = 1
  • ⌊21⌋=2\left \lfloor \frac{2}{1} \right \rfloor = 2, a_2=2a\_2 = 2, this number occurs in the array
  • ⌊51⌋=5\left \lfloor \frac{5}{1} \right \rfloor = 5, a_3=5a\_3 = 5, this number occurs in the array
  • ⌊52⌋=2\left \lfloor \frac{5}{2} \right \rfloor = 2, a_2=2a\_2 = 2, this number occurs in the array

Thus, the condition is met and the array is integral.

In the second test case it is enough to see that

⌊73⌋=⌊213⌋=2\left \lfloor \frac{7}{3} \right \rfloor = \left \lfloor 2\frac{1}{3} \right \rfloor = 2, this number is not in aa, that's why it is not integral.

In the third test case ⌊22⌋=1\left \lfloor \frac{2}{2} \right \rfloor = 1, but there is only 22 in the array, that's why it is not integral.

예제1

  1. 예제 1

    입력
    3
    3 5
    1 2 5
    4 10
    1 3 3 7
    1 2
    2
    
    예상 출력
    Yes
    No
    No