BZOJ 3404: [Usaco2009 Open]Cow Digit Game又见数字游戏(博弈论)

一开始被题意坑了= =,题目是说这个数字的最大和最小,不是个位的最大和最小= =

不知道怎么做只能递推了,必胜态就是存在能到达必败态的,必败态就是只能到达必胜态的

CODE:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAX 1000000
bool b[MAX+2];
int solve(){
 for (int i=1;i<=9;i++) b[i]=1;
 for (int i=10;i<=MAX;i++){
  int ma=0,mi=10,t=i;
  while (t){
   ma=max(t%10,ma);
   mi=t%10==0?mi:min(mi,t%10);
   t/=10;
  }
  b[i]=!(b[i-mi]&b[i-ma]);
 }
}
int main(){
 int t,n;
 scanf("%d",&t);
 solve();
 while (t--) {
  scanf("%d",&n);
  if (b[n]) printf("YES ");
  else printf("NO ");
 }
 return 0;
}

原文地址:https://www.cnblogs.com/New-Godess/p/4348939.html