-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcp247.cpp
44 lines (40 loc) · 896 Bytes
/
cp247.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
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
vector<long long>num;
num[0] = 11;
for(int i=1; i<9; i++){
num[i] = num[i-1]*10 + 1;
}
while(t--){
int n;
cin >> n;
auto it = upper_bound(num.begin(),num.end(), n);
if(it != num.begin()){
it--;
int index = it - num.begin();
while(n>=0){
if(n >= num[index]){
n -= num[index];
}
else{
while(n < num[index]){
index--;
}
}
}
if(n == 0){
cout << "YES" << endl;
}
else{
cout << "NO" << endl;
}
}
else{
cout << "NO" << endl;
}
}
return 0;
}