- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Primary_Task.cpp
More file actions
Latest commit
132 lines (115 loc) · 2.87 KB
/
Copy pathA_Primary_Task.cpp
File metadata and controls
132 lines (115 loc) · 2.87 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include<bits/stdc++.h>
usingnamespacestd;
// Speed
#defineff() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
// Define
#defineintlonglongint
#definevi vector<int>
#definevc vector<char>
#definepyes cout << "YES"<<'\n';
#definepno cout << "NO"<<'\n';
#definedblongdouble
#defineall(x) (x).begin(), (x).end()
#defineMOD (int)(1e9 + 7)
#defineMOD1998244353
#defineinput(start, end, arr) { for(int i = start; i < end; ++i) cin >> arr[i]; }
#definef(i, x, n) for (int i = x; i < n; i++)
#definerf(i, x, n) for (int i = x; i >= n; i--)
#definesz(a) (int)a.size()
#defineppc __builtin_popcount
#defineppcll __builtin_popcountll
#definepi (3.141592653589)
#defineINF1e18
#definenl'\n'
#definesp""
intmod_add(int a, int b, int m) { a = a % m; b = b % m; return (((a + b) % m) + m) % m; }
intmod_mul(int a, int b, int m) { a = a % m; b = b % m; return (((a * b) % m) + m) % m; }
intmod_sub(int a, int b, int m) { a = a % m; b = b % m; return (((a - b) % m) + m) % m; }
intexpo(int a, int b, int mod) { int res = 1; while (b > 0) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b = b >> 1; } return res; }
vi primeFactorization(int n) {
vi factorization;
for (int d = 2; d * d <= n; d++) {
while (n % d == 0) {
factorization.push_back(d);
n /= d;
}
}
if (n > 1) {
factorization.push_back(n);
}
return factorization;
}
vi sieve(int limit) {
vi primes;
vector<bool> is_prime(limit + 1, true);
is_prime[0] = is_prime[1] = false;
for (int i = 2; i <= limit; i++) {
if (is_prime[i]) {
primes.push_back(i);
for (int j = i * i; j <= limit; j += i) {
is_prime[j] = false;
}
}
}
return primes;
}
string getBinary(int n) {
bitset<8> b(n);
return b.to_string();
}
intmaxSubarraySum(int arr[], int n) {
int maxi = INT_MIN;
int sum = 0;
for (int i = 0; i < n; i++) {
sum += arr[i];
if (sum > maxi) {
maxi = sum;
}
if (sum < 0) {
sum = 0;
}
}
return maxi;
}
voidsolve(){
int p;
cin>>p;
string s = to_string(p);
// if(sz(s) < 3){
// cout<<"NO"<<nl;
// return;
// }
// if(sz(s) >= 3 && s[0] == '1' && s[1] == '0' && s[2] != '0' && s[sz(s)-1] != '1'){
// cout<<"YES"<<nl;
// }
// else cout<<"NO"<<nl;
int n = sz(s);
if(n < 3){
cout<<"NO"<<nl;
return;
}
if(s[0] != '1' || s[1] != '0'){
cout<<"NO"<<nl;
return;
}
if(s[2] == '0'){
cout<<"NO"<<nl;
return;
}
if(s == "101"){
cout<<"NO"<<nl;
return;
}
cout<<"YES"<<nl;
// return;
}
int32_tmain() {
ff();
int tc;
cin >> tc;
// tc = 1;
while (tc--) {
solve();
}
return0;
}