-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathksub.cpp
More file actions
40 lines (39 loc) · 778 Bytes
/
ksub.cpp
File metadata and controls
40 lines (39 loc) · 778 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
35
36
37
38
39
40
#include <bits/stdc++.h>
#define ln long long
using namespace std;
int main()
{
// your code goes here
ln num, num1, flag, s, k, i, result;
cin >> num;
while (num--)
{
cin >> num1 >> flag;
vector<ln> a;
k = 0;
for (i = 0; i < num1; i++)
{
cin >> s;
k = __gcd(k, s);
a.push_back(s);
}
s = 0;
result = 0;
for (i = 0; i < num1; i++)
{
s = __gcd(s, a[i]);
if (s == k)
{
result++;
s = 0;
}
}
if (result >= flag)
cout << "yEs"
<< "\n";
else
cout << "nO"
<< "\n";
}
return 0;
}