Game theory
Orz ZYF
Forward backwards ... Anyway the biggest is 10^6, can be violent pre-treatment of each number of the state is to win or be defeated (anyway only two subsequent states), and then O (1) query ... I'm an sb.
1 /**************************************************************2 problem:34043 User:tunix4 language:c++5 result:accepted6 time:880 Ms7 memory:5180 KB8 ****************************************************************/9 Ten //Bzoj 3404 One#include <cstdio> A#include <iostream> -#include <algorithm> - #defineF (i,j,n) for (int i=j;i<=n;++i) the using namespacestd; - intGetint () { - intv=0, sign=1;CharCh=GetChar (); - while(!isdigit (CH)) {if(ch=='-') sign=-1; Ch=GetChar ();} + while(IsDigit (CH)) {v=v*Ten+ch-'0'; Ch=GetChar ();} - returnv*Sign ; + } A Const intn=1e6+Ten, inf=~0u>>2; at /*******************template********************/ - intf[n+ -]; - intMain () { -f[0]=0; -F (I,1, N) { - intx=i,mx=0, mn=Ten, t=0; in while(x) {t=x%Ten; Mx=max (mx,t);if(t) mn=min (MN,T); X/=Ten;} - if(!f[i-mx] | |!f[i-mn]) f[i]=1; to } + intt=getint (); - while(t--) theprintf (F[getint ())?"yes\n":"no\n"); * return 0; $}
View Code
"Bzoj" "3404" "USACO2009 Open" Cow Digit game See also number games