-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1770C Koxia and Number Theory.cpp
63 lines (61 loc) · 1.13 KB
/
1770C Koxia and Number Theory.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
55
56
57
58
59
60
61
62
63
/*
author : MishkatIT
created : Saturday 2022-12-31-20.05.01
problem : C. Koxia and Number Theory
*/
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
using namespace std;
void solve(void)
{
int n;
cin >> n;
int arr[n];
map<int, int> mp;
for (int i = 0; i < n; i++)
{
cin >> arr[i];
mp[arr[i]]++;
}
for (auto& i: mp)
{
if(i.second > 1)
{
cout << "NO" << '\n';
return;
}
}
bool ok = true;
for (int mod = 2; mod < n; mod++)
{
vector<int> cnt(mod);
for (int i = 0; i < n; i++)
cnt[arr[i] % mod]++;
bool isOne = false;
for (int i = 0; i < mod; i++)
{
if(cnt[i] < 2)
{
isOne = true;
break;
}
}
if(!isOne)
{
ok = false;
break;
}
}
cout << (ok ? "YES" : "NO") << '\n';
return;
}
signed main()
{
fio;
int t;
cin >> t;
while(t--)
solve();
return 0;
}