-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathe.cpp
57 lines (54 loc) · 985 Bytes
/
e.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
#include <bits/stdc++.h>
#define endl '\n'
#define eat cin
#define moo cout
#define int long long
using namespace std;
int T, N, A[200000];
int32_t main(){
eat.tie(0) -> sync_with_stdio(0);
eat >> T;
while(T--){
eat >> N;
bool tl = 0, fl = 0;
for(int i = 0; i < N; i++){
eat >> A[i];
if(A[i] % 10 == 0 || A[i] % 10 == 5) fl = 1;
else tl = 1;
if(A[i] % 2 == 1){
A[i] += A[i] % 10;
}
}
if(fl && tl){
moo << "No" << endl;
continue;
}
if(fl){
for(int i = 0; i < N; i++){
if(A[i] % 10 == 5) A[i] += 5;
}
bool ok = 1;
for(int i = 1; i < N; i++){
if(A[i] != A[i-1]) ok = 0;
}
if(ok) moo << "Yes" << endl;
else moo << "No" << endl;
continue;
}
for(int i = 0; i < N; i++){
if(A[i] % 10 == 6){
A[i] += 10;
}
A[i] /= 10;
}
bool good = 1;
for(int i = 1; i < N; i++){
if(A[i] % 2 != A[i-1] % 2){
good = 0;
break;
}
}
if(good) moo << "Yes" << endl;
else moo << "No" << endl;
}
}