提交记录
#include<cstdio>
using namespace std;
#define N 1000005
bool dp[N],vis[N];
bool dfs(int n)
{
if(vis[n])
return dp[n];
vis[n]=1;
if(n==0)
return dp[n]=0;
int t=n;
while(t)
{
int f=t%10;
t/=10;
if(f&&!dfs(n-f))
return dp[n]=1;
}
return dp[n]=0;
}
signed main()
{
int tt;
scanf("%d",&tt);
while(tt--)
{
int n;
scanf("%d",&n);
puts((dfs(n)?"YES":"NO"));
}
return 0;
}