https://ac.nowcoder.com/acm/contest/1071/G
思路:打表递推出sg数组;
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <map>
using namespace std;
#define fl() printf("flag!\n")
#define INF 0x3f3f3f3f
#define ll long long
#define mem(x,y) memset(x,y,sizeof(x))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const int maxn=1e6+9;
const int mod=1e9+7;
bool sg[maxn];
void SG()
{
sg[0]=0;
for(int i=1;i<=9;i++) sg[i]=1;
for(int i=10;i<=1000000;i++)
{
int tmp=i;
int Min=10;
int Max=0;
while(tmp)
{
Max=max(Max,tmp%10);
if(tmp%10!=0) Min=min(Min,tmp%10);
tmp/=10;
}
sg[i]=(sg[i-Min]^1)||(sg[i-Max]^1);
//cout<<sg[i]<<" ";
}
}
int main()
{
//FAST_IO;
SG();
int t;
cin>>t;
for(int i=1;i<=t;i++)
{
int n;
cin>>n;
if(sg[n]) puts("YES");
else puts("NO");
}
return 0;
}