题目:

​题目链接​

题解:

#include <bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int f[N];
int ma(int x)
{
int ans=0;
while(x)
{
int d=x%10;
ans=max(ans, d);
x/=10;
}
return ans;
}
int mi(int x)
{
int ans=10;
while(x)
{
int d=x%10;
if(d) ans=min(ans, d);
x/=10;
}
return ans;
}
void init()
{
for(int i=1; i<=9; i++) f[i]=1;

for(int i=0; i<N; i ++ )
{
if(!f[i-ma(i)] || !f[i-mi(i)]) f[i]=1;
}
}
int main()
{
init();
int t;
cin >> t;
while(t -- )
{
long long n;
cin >> n;
if(f[n]) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}