You are given an array A of N positive integers. Let G be the [gcd] of all the numbers in the array A. 
 
You have to find if there exist K non-empty, non-intersecting subarrays of A for which the [arithmetic mean] of the gcd of those K subarrays equals G.

Formally, let g_{1}, g_{2}, \ldots, g_{K} be the gcd of those K chosen subarrays, then, \frac{(g_{1} + g_{2} + .... + g_{K})}{K} = G should follow.

If there exist K such subarrays, output YES, otherwise output NO.

Note: Two subarrays are non-intersecting if there exists no index i, such that, A_{i} is present in both the subarrays.

------ Input Format ------ 

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line of each test case contains two space-separated integers — the number of integers in the array A and the integer K, respectively.
- The next line contains N space-separated positive integers A_{1}, A_{2}, \ldots, A_{N}, the elements of the array A.

------ Output Format ------ 

For each test case, if there exist K such subarrays, output YES, otherwise output NO.

You may print each character of the string in uppercase or lowercase (for example, the strings YES, yEs, yes, and yeS will all be treated as identical).

------ Constraints ------ 

$1 ≤ T ≤ 1000$
$1 ≤ N ≤ 2 \cdot {10}^5$
$1 ≤ K ≤ N$
$1 ≤ A_{i} ≤ 2 \cdot {10}^5$
- The sum of $N$ over all test cases won't exceed $4 \cdot {10}^5$.

----- Sample Input 1 ------ 
4
6 4
2 2 3 3 2 2
1 1
1
5 3
1 2 3 4 5
4 3
6 12 18 24
----- Sample Output 1 ------ 
NO
YES
YES
NO

----- explanation 1 ------ 
Test case $1$: It is impossible to find $4$ non-empty, non-intersecting subarrays which satisfy the given condition.

Test case $2$: There is only one element in the array. Here, $G = 1$ and, for the subarray $[1]$, $g = 1$. Thus, it is possible to satisfy the conditions. 

Test case $3$: Here, $G = gcd(1,2,3,4,5) = 1$. We can choose $3$ non-empty, non-intersecting subarrays $\{[1], [2,3], [4,5]\}$ where $gcd(1) = 1$, $gcd(2,3) = 1$, and $gcd(4,5) = 1$. Thus, the arithmetic mean = $\frac{(1 + 1 + 1)}{3} = 1$. Hence, we can have $3$ such subarrays.  

Test case $4$: It is impossible to find $3$ non-empty, non-intersecting subarrays which satisfy the given condition.

Difficulty: MEDIUM_HARD
Tags: Number theory

Mathematics

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
import math
T = int(input())
for i in range(T):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	All = 0
	for j in range(a):
		All = math.gcd(All, l[j])
	ind = 0
	curr = 0
	temp = 0
	while ind < a and temp < b:
		curr = 0
		while ind < a and curr != All:
			curr = math.gcd(curr, l[ind])
			ind += 1
		if curr == All:
			temp += 1
	if temp == b:
		print('YES')
	else:
		print('NO')


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for z in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	g = a[0]
	for x in a:
		g = gcd(g, x)
	p = a[0]
	j = 0
	for i in range(n):
		p = gcd(p, a[i])
		if p == g:
			j += 1
			if i == n - 1:
				break
			p = a[i + 1]
	if j >= k:
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	if a % b == 0:
		return b
	else:
		return gcd(b, a % b)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	if len(a) == 1:
		print('YES')
	else:
		l = gcd(a[0], a[1])
		for j in range(2, len(a)):
			y = gcd(l, a[j])
			l = y
		r = 0
		for x in a:
			c = gcd(c, x)
			if c == y:
				c = 0
				r = r + 1
		if r >= k:
			print('YES')
		else:
			print('NO')


import math as m
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	x = 0
	ans = 0
	for i in a:
		x = m.gcd(x, i)
	curr = 0
	for i in a:
		curr = m.gcd(curr, i)
		if curr == x:
			curr = 0
			ans += 1
	if ans >= k:
		print('YES')
	else:
		print('NO')


import math

def isKGoodArray(nums, k):
	arrayGcd = 0
	for num in nums:
		arrayGcd = math.gcd(arrayGcd, num)
	subarrayGcd = 0
	numSubarrays = 0
	for i in range(len(nums)):
		subarrayGcd = math.gcd(nums[i], subarrayGcd)
		if subarrayGcd == arrayGcd:
			subarrayGcd = 0
			numSubarrays += 1
	return numSubarrays >= k
numTestCases = int(input())
for i in range(numTestCases):
	(n, k) = [int(i) for i in input().split(' ')]
	nums = [int(i) for i in input().split(' ')]
	result = 'YES' if isKGoodArray(nums, k) else 'NO'
	print(result)


import math

def gcd_arr(arr, f_gcd):
	sum = 0
	i = 0
	while i < len(arr):
		if arr[i] == f_gcd:
			sum += 1
			i += 1
		else:
			temp = arr[i]
			i += 1
			possib = False
			while i <= len(arr):
				if temp == f_gcd:
					possib = True
					break
				if i == len(arr):
					break
				temp = math.gcd(temp, arr[i])
				i += 1
			if possib == True:
				sum += 1
	return sum
k = int(input())
arr = []
for i in range(k):
	(n, m) = input().split()
	(n, m) = (int(n), int(m))
	arr = input().split()
	arr = [int(l) for l in arr]
	f_gcd = arr[0]
	for j in range(1, n):
		f_gcd = math.gcd(f_gcd, arr[j])
	if gcd_arr(arr, f_gcd) >= m:
		print('YES')
	else:
		print('NO')


def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def gcd_of_list(l):
	gcd = 0
	for i in range(len(l)):
		gcd = find_gcd(gcd, l[i])
	return gcd
for i in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	t = gcd_of_list(l)
	count = 0
	temp_gcd = 0
	for i in range(n):
		temp_gcd = find_gcd(temp_gcd, l[i])
		if temp_gcd == t:
			count += 1
			temp_gcd = 0
	if count >= k:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	g = 0
	for num in arr:
		g = math.gcd(g, num)
	cnt = 0
	tg = 0
	for num in arr:
		tg = math.gcd(tg, num)
		if tg == g:
			cnt += 1
			tg = 0
	if cnt >= k:
		print('YES')
	else:
		print('NO')


from math import gcd
from functools import reduce
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	G = reduce(gcd, a)
	cur = taken = 0
	for i in a:
		cur = gcd(cur, i)
		if cur == G:
			cur = 0
			taken += 1
	if taken >= k:
		print('YES')
	else:
		print('NO')


import math
T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	L = list(map(int, input().split()))
	G = 0
	for i in range(N):
		G = math.gcd(G, L[i])
	count = 0
	g = 0
	for i in range(N):
		g = math.gcd(g, L[i])
		if g == G:
			count = count + 1
			g = 0
	if count >= K:
		print('YES')
	else:
		print('NO')


import math
from functools import reduce
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	L = list(map(int, input().split()))
	g = reduce(math.gcd, L)
	if x == y:
		if len(set(L)) == 1:
			print('YES')
		else:
			print('NO')
		continue
	if y == 1:
		print('YES')
		continue
	sarr = 0
	ind = 0
	while ind < x and sarr < y:
		currentgcd = 0
		while ind < x and currentgcd != g:
			currentgcd = math.gcd(currentgcd, L[ind])
			ind += 1
		if currentgcd == g:
			sarr += 1
	if sarr == y:
		print('YES')
	else:
		print('NO')


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return abs(x)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	g = 0
	for i in range(n):
		g = gcd(g, a[i])
	cur = 0
	ans = 0
	for i in range(n):
		cur = gcd(cur, a[i])
		if cur == g:
			cur = 0
			ans += 1
	if ans >= k:
		print('YES')
	else:
		print('NO')


def hcfnaive(a, b):
	if a == 1 or b == 1:
		return 1
	if b == 0:
		return abs(a)
	else:
		return hcfnaive(b, a % b)
T = int(input())
for _ in range(T):
	data = list(map(int, input().strip().split()))
	k = data[1]
	N = data[0]
	array = list(map(int, input().strip().split()))
	gcd = array[0]
	for i in range(1, N):
		gcd = hcfnaive(gcd, array[i])
	tempgcd = 0
	for i in range(0, N):
		if tempgcd == 0:
			tempgcd = array[i]
		tempgcd = hcfnaive(tempgcd, array[i])
		if gcd == tempgcd:
			k -= 1
			tempgcd = 0
	if k > 0:
		print('NO')
	else:
		print('YES')


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	G = 0
	count = 0
	for i in a:
		G = math.gcd(i, G)
	g1 = 0
	for i in a:
		g1 = math.gcd(i, g1)
		if g1 == G:
			count += 1
			g1 = 0
	if count >= k:
		print('YES')
	else:
		print('NO')


from math import gcd
t = int(input())
for i in range(0, t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	A = list(map(int, input().split()))
	hcf = 0
	for i in A:
		hcf = gcd(hcf, i)
	gcd1 = 0
	count = 0
	for i in A:
		gcd1 = gcd(gcd1, i)
		if gcd1 == hcf:
			count += 1
			gcd1 = 0
	if count >= k:
		print('YES')
	else:
		print('NO')


from math import gcd
for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	g = 0
	for i in a:
		g = gcd(g, i)
	g1 = 0
	c = 0
	for i in a:
		g1 = gcd(g1, i)
		if g1 == g:
			c += 1
			g1 = 0
	if c >= k:
		print('YES')
	else:
		print('NO')


import math
test = int(input())
for i in range(test):
	(size, k) = list(map(int, input().split()))
	nums = list(map(int, input().split()))
	arr_gcd = nums[0]
	for j in range(1, len(nums)):
		arr_gcd = math.gcd(arr_gcd, nums[j])
	finres = False
	gcd = 0
	count = 0
	for k1 in nums:
		gcd = math.gcd(gcd, k1)
		if gcd == arr_gcd:
			count += 1
			gcd = 0
			if count == k:
				finres = True
				break
	if finres == True:
		print('YES')
	else:
		print('NO')


import math
t = int(input(''))
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	current_gcd = arr[0]
	for i in range(1, n):
		current_gcd = math.gcd(current_gcd, arr[i])
	count = 0
	solution = False
	g = 0
	for i in range(n):
		g = math.gcd(g, arr[i])
		if g == current_gcd:
			count += 1
			g = 0
			if count == k:
				solution = True
	if solution:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
while t != 0:
	t = t - 1
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	m = max(l)
	g = m
	for i in range(n):
		g = math.gcd(l[i], g)
	c = l[0]
	for i in range(n):
		c = math.gcd(c, l[i])
		if c == g:
			k = k - 1
			if i + 1 == n:
				break
			else:
				c = l[i + 1]
	if k > 0:
		print('NO')
	else:
		print('YES')


from math import gcd
for i in range(int(input())):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	curr_gcd = 0
	for i in A:
		curr_gcd = gcd(curr_gcd, i)
	x = 0
	g = 0
	for i in A:
		g = gcd(g, i)
		if g == curr_gcd:
			K -= 1
			g = 0
	if K <= 0:
		print('YES')
	else:
		print('NO')


from math import gcd
t = int(input())
for _ in range(t):
	(a, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	curr_gcd = 0
	for i in arr:
		curr_gcd = gcd(curr_gcd, i)
	ans = 0
	g = 0
	for i in arr:
		g = gcd(g, i)
		if g == curr_gcd:
			k -= 1
			g = 0
	if k <= 0:
		print('YES')
	else:
		print('NO')


import math
for tc in range(int(input())):
	(n, k) = map(int, input().split())
	elements = list(map(int, input().split()))
	gcd = elements[0]
	for i in range(1, n):
		gcd = math.gcd(gcd, elements[i])
	cnt = 0
	g = 0
	has_solution = False
	for i in range(n):
		g = math.gcd(g, elements[i])
		if g == gcd:
			g = 0
			cnt += 1
			if cnt == k:
				has_solution = True
				break
	if has_solution:
		print('YES')
	else:
		print('NO')


from functools import reduce

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
for _ in range(int(input())):
	(len, K) = map(int, input().split())
	arr = list(map(int, input().split()))
	G = reduce(gcd, arr)
	(curG, count) = (0, 0)
	for i in range(len):
		curG = gcd(curG, arr[i])
		if curG == G:
			count += 1
			curG = 0
		if count == K:
			break
	if count == K:
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	if a > b:
		(a, b) = (b, a)
	while True:
		rem = b % a
		if rem == 0:
			return a
		b = a
		a = rem
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	g = A[0]
	G = A[0]
	for i in range(n):
		G = gcd(A[i], G)
	c = 0
	for i in range(n):
		g = gcd(g, A[i])
		if g == G:
			c += 1
			if i + 1 < n:
				g = A[i + 1]
			else:
				break
	if c >= k:
		print('YES')
	else:
		print('NO')


def solve(n1, n2, l):
	gcd = l[0]
	for i in range(1, n1):
		gcd = math.gcd(gcd, l[i])
	count = 0
	check = -1
	for i in range(0, len(l)):
		if check == gcd:
			count += 1
			check = l[i]
		elif check == -1:
			check = l[i]
		else:
			check = math.gcd(check, l[i])
	if check == gcd:
		count += 1
	if count >= n2:
		return 'YES'
	else:
		return 'NO'
import math
n = int(input())
while n:
	(n1, n2) = map(int, input().split())
	l = list(map(int, input().split()))
	print(solve(n1, n2, l))
	n -= 1


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	G = 0
	for i in arr:
		G = gcd(G, i)
	cur = 0
	ans = 0
	for i in arr:
		cur = gcd(cur, i)
		if cur == G:
			ans += 1
			cur = 0
		if ans == k:
			break
	if ans == k:
		print('YES')
	else:
		print('NO')


from math import gcd
t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	G = 0
	for i in a:
		G = gcd(G, i)
	cur_gcd = 0
	count = 0
	for i in a:
		cur_gcd = gcd(cur_gcd, i)
		if cur_gcd == G:
			count += 1
			cur_gcd = 0
	print('YES' if count >= k else 'NO')
	t -= 1


from math import *
for i in range(int(input())):
	(n, k) = map(int, input().split())
	list_a = list(map(int, input().split()))
	G = list_a[0]
	counter = 0
	for j in list_a:
		G = gcd(G, j)
	sub_G = 0
	for j in list_a:
		sub_G = gcd(sub_G, j)
		if G == sub_G:
			counter += 1
			sub_G = 0
	if counter >= k:
		print('YES')
	else:
		print('NO')


def rt(n, k):
	p = n[0]
	for i in range(1, len(n)):
		p = gcd(p, n[i])
	t = n[0]
	r = 0
	for i in range(0, len(n)):
		t = gcd(t, n[i])
		if t == p:
			r = r + 1
			if i != len(n) - 1:
				t = n[i + 1]
	if r >= k:
		print('YES')
	else:
		print('NO')

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
x = int(input())
for i in range(0, x):
	[a, b] = input().split(' ')
	a = int(a)
	b = int(b)
	x = [int(j) for j in input().split(' ')]
	rt(x, b)


def hcf(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def possible(arr, N, K):
	if len(arr) == 1:
		return True
	num1 = arr[0]
	num2 = arr[1]
	gcd = hcf(num1, num2)
	for i in range(2, len(arr)):
		gcd = hcf(gcd, arr[i])
	count = 0
	current_gcd = 0
	for i in range(N):
		current_gcd = hcf(current_gcd, arr[i])
		if current_gcd == gcd:
			current_gcd = 0
			count += 1
	if count >= K:
		return True
	return False
for i in range(int(input())):
	(N, K) = tuple(map(int, input().split(' ')))
	arr = list(map(int, input().split(' ')))
	if possible(arr, N, K):
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	k = l[1]
	arr = list(map(int, input().split()))
	c = 0
	G = 0
	g = 0
	for l in arr:
		G = math.gcd(G, l)
	for i in range(len(arr)):
		g = math.gcd(g, arr[i])
		if g == G:
			c += 1
			g = 0
		else:
			continue
	if c >= k:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	G = a[0]
	for i in range(1, len(a)):
		G = math.gcd(G, a[i])
	c = 0
	i = 0
	g = a[i]
	while i < len(a):
		g = a[i]
		if g == G:
			c = c + 1
			i = i + 1
			continue
		if i + 1 == len(a):
			break
		else:
			for j in range(i + 1, len(a)):
				g = math.gcd(g, a[j])
				if g == G:
					c = c + 1
					i = j + 1
					break
				if j == len(a) - 1:
					i = len(a)
	if c >= k:
		print('YES')
	else:
		print('NO')


import math
n = int(input())
for k in range(n):
	(N, K) = map(int, input().split())
	krr = list(map(int, input().strip().split()))[:N]
	ans = 0
	count = 0
	X = 0
	for i in range(len(krr)):
		ans = math.gcd(ans, krr[i])
	for i in range(len(krr)):
		X = math.gcd(X, krr[i])
		if X == ans:
			X = 0
			count += 1
	if count >= K:
		print('YES')
	else:
		print('NO')


from math import gcd
T = int(input())
for t in range(1, T + 1):
	inp = list(map(int, input().split()))
	N = inp[0]
	K = inp[1]
	arr = list(map(int, input().split()))
	count = 0
	G = 0
	for i in range(N):
		G = gcd(G, arr[i])
	x = 0
	for i in range(N):
		x = gcd(x, arr[i])
		if x == G:
			count += 1
			x = 0
	if count >= K:
		print('YES')
	else:
		print('NO')


import math
for _ in range(int(input())):
	(n, kk) = map(int, input().split())
	a = list(map(int, input().split()))
	gc = 0
	for i in range(len(a)):
		gc = math.gcd(gc, a[i])
	k = 0
	c = 0
	j = 0
	while j < len(a):
		k = math.gcd(k, a[j])
		if k != gc:
			j += 1
		else:
			c += 1
			k = 0
			j += 1
	if c >= kk:
		print('YES')
	else:
		print('NO')


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	G = 0
	for i in arr:
		G = math.gcd(G, i)
	x = 0
	count = 0
	for i in arr:
		x = math.gcd(x, i)
		if x == G:
			x = 0
			count += 1
	if count >= k:
		print('YES')
	else:
		print('NO')


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = inp()
for i in range(t):
	(n, k) = mp()
	l = li()
	g = l[0]
	for i in l:
		g = gcd(g, i)
	c = 0
	x = 0
	for i in l:
		x = gcd(x, i)
		if x == g:
			x = 0
			c += 1
	if c >= k:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
import math

class T:

	def solve(self):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		d = defaultdict(int)
		ans = self.gcd(a, n)
		sgcd = 0
		count = 0
		d[0] = 1
		for i in range(n):
			sgcd = math.gcd(sgcd, a[i])
			if sgcd == ans:
				sgcd = 0
				count += 1
		if count >= k:
			return 'YES'
		return 'NO'

	def gcd(self, a, n):
		ans = a[0]
		for i in range(1, n):
			ans = math.gcd(ans, a[i])
		return ans
for t in range(int(input())):
	obj = T()
	print(obj.solve())


import math
from collections import Counter
from collections import defaultdict
import sys

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def solve(n, k, arr):
	g = 0
	for i in arr:
		g = math.gcd(g, i)
	gg = 0
	cnt = 0
	j = 0
	while j < len(arr):
		gg = math.gcd(arr[j], gg)
		if gg != g:
			j += 1
		else:
			cnt += 1
			gg = 0
			j += 1
	if cnt >= k:
		return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	n = get_ints()
	arr = get_ints()
	print(solve(n[0], n[1], arr))


import math
T = int(input())
for _ in range(T):
	(N, K) = [int(i) for i in input().split(' ')]
	A = [int(i) for i in input().split(' ')]
	G = 0
	for i in range(N):
		G = math.gcd(G, A[i])
	g = 0
	c = 0
	for i in range(N):
		g = math.gcd(g, A[i])
		if g == G:
			g = 0
			c += 1
	if c >= K:
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def gcd_list(arr):
	res = arr[0]
	for i in range(1, len(arr)):
		res = gcd(*sorted([res, arr[i]]))
	return res
t = int(input())
for i in range(t):
	(n, k) = [int(el) for el in input().split(' ')]
	arr = [int(el) for el in input().split(' ')]
	g = gcd_list(arr)
	count = 0
	current = arr[0]
	for j in range(1, n):
		if current == g:
			count += 1
			current = arr[j]
		else:
			current = gcd(*sorted([current, arr[j]]))
	if current == g:
		count += 1
	if count >= k:
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	g = min(a)
	count = 0
	for j in a:
		if j % g != 0:
			g = 1
			break
	p = 0
	for j in range(0, n):
		p = gcd(p, a[j])
		if p == g:
			count += 1
			p = 0
	if count >= k:
		print('YES')
	else:
		print('NO')


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	G = 0
	for i in range(n):
		G = math.gcd(G, l[i])
	g = 0
	count = 0
	flag = 0
	for i in range(n):
		g = math.gcd(g, l[i])
		if g == G:
			count += 1
			g = 0
		if count == k:
			flag = 1
	if flag:
		print('YES')
	else:
		print('NO')


import os.path
from math import gcd, floor, ceil, log2
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def gcd_fn(a, n):
	g = a[0]
	for i in range(1, n):
		g = gcd(g, a[i])
	return g
for _ in range(int(input())):
	(n, k) = mp()
	a = li()
	G = gcd_fn(a, n)
	res = 0
	x = 0
	for i in range(n):
		x = gcd(x, a[i])
		if x == G:
			res += 1
			x = 0
	if res >= k:
		pr('YES')
	else:
		pr('NO')


for i in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))

	def gcd(a, b):
		if b == 0:
			return a
		else:
			return gcd(b, a % b)
	G = 0
	for i in range(n):
		G = gcd(G, arr[i])
	count = 0
	subG = 0
	for i in range(n):
		subG = gcd(subG, arr[i])
		if subG == G:
			subG = 0
			count += 1
	if count >= k:
		print('YES')
	else:
		print('NO')


import math
for t in range(int(input())):
	(le, k) = [int(i) for i in input().split()]
	l1 = [int(i) for i in input().split()]
	g = l1[0]
	for ele in l1:
		g = math.gcd(g, ele)
	c = 0
	ng = 0
	for i in range(le):
		ng = math.gcd(ng, l1[i])
		if ng == g:
			c += 1
			ng = 0
	if c >= k:
		print('YES')
	else:
		print('NO')


from math import gcd
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	(g, curr, ans) = (0, 0, 0)
	for i in l:
		g = gcd(g, i)
	for i in l:
		curr = gcd(curr, i)
		if curr == g:
			curr = 0
			ans += 1
	print('YES' if ans >= k else 'NO')


import math
from bisect import bisect_left
from code import interact
from heapq import heapify, heappush, heappop
from collections import deque
from pydoc import plain
from re import X
import sys
from math import gcd, sqrt, log10, log2, floor, ceil, sqrt
input = sys.stdin.readline

def il():
	return [int(a) for a in input().strip().split()]

def ip():
	return input().strip()

def ii():
	return int(input())

def ot(in_p, *args, e=' '):
	if type(in_p) == list:
		print(*in_p, end=e)
	if type(in_p) == str or type(in_p) == int:
		print(in_p, end=e)
		for l in args:
			print(l, end=e)
	print()

def a_pwr_n(a, n, mod):
	if n == 1:
		return a % mod
	if n % 2 == 0:
		val = a_pwr_n(a, n // 2, mod)
		return val % mod * val % mod
	else:
		return a % mod * a_pwr_n(a, n - 1, mod) % mod

def rg(*ag):
	if len(ag) == 3:
		return range(ag[0], ag[1], ag[2])
	elif len(ag) == 2:
		return range(ag[0], ag[1])
	elif len(ag) == 1:
		return range(ag[0])
	else:
		raise 'invalid input'

def ispal(i, j, st):
	while i <= j:
		if st[i] == st[j]:
			i = i + 1
			j = j - 1
		else:
			return False
	return True
mod = 1000000000 + 7
dx = [-1, -2, 1, 2, 2, -2, -1, 1]
dy = [2, 1, 2, 1, -1, -1, -2, -2]

def k_subarrays(array, size, k):
	(_gcd, temp, temp2) = (0, 0, 0)
	for item in array:
		_gcd = math.gcd(_gcd, item)
	for item in array:
		temp = math.gcd(temp, item)
		if temp == _gcd:
			temp2 += 1
			temp = 0
	if temp2 >= k:
		return True
	else:
		return False
for i in range(ii()):
	(size, y) = il()
	array = il()
	if k_subarrays(array, size, y):
		print('YES')
	else:
		print('NO')


from math import gcd
from functools import reduce
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	flag = True
	g = reduce(gcd, a)
	x = 0
	for i in range(n):
		x = gcd(x, a[i])
		if x == g:
			x = 0
			c += 1
	print('YES' if c >= k else 'NO')


from math import gcd
from functools import reduce
for i in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	G = reduce(gcd, l)
	cur = cnt = 0
	for i in range(n):
		cur = gcd(cur, l[i])
		if cur == G:
			cur = 0
			cnt += 1
	if cnt >= k:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	nums = list(map(int, input().split()))
	cnt = 0
	_gcd = 0
	g = 0
	for i in nums:
		g = math.gcd(g, i)
	for i in nums:
		_gcd = math.gcd(_gcd, i)
		if _gcd == g:
			cnt += 1
			_gcd = 0
	if cnt >= b:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	(a, k) = map(int, input().split())
	n = [int(i) for i in input().split()]
	g = 0
	for i in n:
		g = math.gcd(i, g)
	p = 0
	count = 0
	for i in n:
		p = math.gcd(i, p)
		if p == g:
			count += 1
			p = 0
	if count >= k:
		print('YES')
	else:
		print('NO')


t = int(input())

def gcd(a, b):
	while b != 0:
		(a, b) = (b, a % b)
	return a
while t:
	(a, k) = map(int, input().split())
	l = list(map(int, input().split()))
	res = l[0]
	for i in l:
		res = gcd(res, i)
	g = 0
	c = 0
	for i in l:
		g = gcd(g, i)
		if g == res:
			c += 1
			g = 0
	if c >= k:
		print('YES')
	else:
		print('NO')
	t -= 1


from math import gcd
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	G = 0
	for i in range(n):
		G = gcd(G, arr[i])
	c = 0
	subG = 0
	for i in range(n):
		subG = gcd(subG, arr[i])
		if subG == G:
			c = c + 1
			subG = 0
	if c >= k:
		print('YES')
	else:
		print('NO')


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = list(map(int, input().split()))
	g_c = 0
	for j in x:
		g_c = math.gcd(g_c, j)
	count = 0
	curr = 0
	for j in x:
		curr = math.gcd(curr, j)
		if curr == g_c:
			count += 1
			curr = 0
	if count >= k:
		print('YES')
	else:
		print('NO')


from math import gcd
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(map(int, input().split()))
	g = 0
	for i in range(n):
		g = gcd(g, s[i])
	if g != 1:
		for i in range(n):
			s[i] //= g
	cnt = 0
	gc = 0
	for i in range(n):
		gc = gcd(gc, s[i])
		if gc == 1:
			cnt += 1
			gc = 0
	if cnt >= k:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	(a, k) = map(int, input().split())
	n = list(map(int, input().split()))
	x = n[0]
	for i in n:
		x = math.gcd(i, x)
	g = n[0]
	c = 0
	for i in range(a):
		g = math.gcd(n[i], g)
		if g == x:
			c = c + 1
			if i != len(n) - 1:
				g = n[i + 1]
	if c >= k:
		print('YES')
	else:
		print('NO')