-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path937d.cpp
More file actions
90 lines (68 loc) · 1.24 KB
/
937d.cpp
File metadata and controls
90 lines (68 loc) · 1.24 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
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int dx[]={0,-1,0,1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
char dir[]={'R','U','L','D'};
#define nl '\n'
#define s_i stoi(string s)
#define i_s to_string(num)
const ll INF=numeric_limits<ll>::max()-1;
#define ll_inf (1LL << 62)
#define inf (1 << 30)
#define SetBit(x, k) (x = (1LL << k))
#define ClearBit(x, k) (x &= ~(1LL << k))
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
int32_t main()
{ fast
vector<int>v={10,11,110,101,1111,1011,1101,1110,1001,1100,1000};
map<int,int>m;
for(int i=0;i<v.size();i++) m[v[i]]++;
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int p=n;
int x=n;
int mx=-1;
while(p)
{
mx=max(mx,p%10);
p=p/10;
}
if(m.find(n)!=m.end())
{
cout<<"YES"<<'\n';
continue;
}
if(p>6)
{
cout<<"NO"<<'\n';
continue;
}
bool ok=true;
while(x!=1)
{
int q=0;
for(int i=0;i<v.size();i++)
{
if(x%v[i]==0)
{
x=x/v[i];
q++;
}
}
if(q==0)
{
ok=false;
break;
}
}
if(ok) cout<<"YES"<<'\n';
else cout<<"NO"<<'\n';
}
}