forked from 21171-somesh/CodeforcesSolutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1203B.cpp
54 lines (48 loc) · 850 Bytes
/
1203B.cpp
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int arr[402];
map<int,int> mp;
int mult;
int main() {
int t, n;
int aux;
scanf("%d", &t);
while(t--) {
scanf("%d", &n);
for (int i = 0; i < 4*n; ++i)
{
scanf("%d", &arr[i]);
if (mp.find(arr[i])==mp.end()){
mp[arr[i]] = 1;
}
else
{
mp[arr[i]]++;
}
}
bool ans = true;
for (auto p: mp)
{
if (p.second %2 ==1)
{
ans = false;
break;
}
}
mp.clear();
if (ans)
{
sort(arr,arr+4*n,greater<int>());
mult = arr[0]*arr[4*n-1];
for (int i = 0; i < 2*n; i = i+2)
{
if (mult == arr[i]*arr[4*n-i-1]) continue;
ans = false;
}
}
if (ans) printf("YES\n");
else printf("NO\n");
}
}