-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddmodulo1400.cpp
More file actions
51 lines (47 loc) · 1.02 KB
/
addmodulo1400.cpp
File metadata and controls
51 lines (47 loc) · 1.02 KB
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
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;
int next(int x) {
return x + x % 10;
}
void solve() {
int n;
cin >> n;
vector<int> a(n);
bool flag = false;
for (int i = 0; i < n; ++i) {
cin >> a[i];
if (a[i] % 5 == 0) {
flag = true;
a[i] = next(a[i]);
}
}
if (flag) {
cout << (*min_element(a.begin(), a.end()) == *max_element(a.begin(), a.end()) ? "Yes": "No") << '\n';
} else {
bool flag2 = false, flag12 = false;
for (int i = 0; i < n; ++i) {
int x = a[i];
while (x % 10 != 2) {
x = next(x);
}
if (x % 20 == 2) {
flag2 = true;
} else {
flag12 = true;
}
}
cout << ((flag2 & flag12) ? "No" : "Yes") << '\n';
}
}
int main() {
int t = 1;
cin >> t;
for (int it = 0; it < t; ++it) {
solve();
}
return 0;
}