• 【BZOJ】【3404】【USACO2009 Open】Cow Digit Game又见数字游戏


    博弈论

      Orz ZYF

      从前往后递推……反正最大才10^6,完全可以暴力预处理每个数的状态是必胜还是必败(反正才两个后继状态),然后O(1)查询……我是SB

     1 /**************************************************************
     2     Problem: 3404
     3     User: Tunix
     4     Language: C++
     5     Result: Accepted
     6     Time:880 ms
     7     Memory:5180 kb
     8 ****************************************************************/
     9  
    10 //BZOJ 3404
    11 #include<cstdio>
    12 #include<iostream>
    13 #include<algorithm>
    14 #define F(i,j,n) for(int i=j;i<=n;++i)
    15 using namespace std;
    16 int getint(){
    17     int v=0,sign=1; char ch=getchar();
    18     while(!isdigit(ch)) {if(ch=='-') sign=-1; ch=getchar();}
    19     while(isdigit(ch))  {v=v*10+ch-'0'; ch=getchar();}
    20     return v*sign;
    21 }
    22 const int N=1e6+10,INF=~0u>>2;
    23 /*******************template********************/
    24 int f[N+100];
    25 int main(){
    26     f[0]=0;
    27     F(i,1,N){
    28         int x=i,mx=0,mn=10,t=0;
    29         while(x){ t=x%10; mx=max(mx,t); if (t)mn=min(mn,t); x/=10;}
    30         if (!f[i-mx] || !f[i-mn]) f[i]=1;
    31     }
    32     int T=getint();
    33     while(T--)
    34         printf( f[getint()] ? "YES
    " : "NO
    ");
    35     return 0;
    36 }
    View Code
  • 相关阅读:
    const修饰指针
    C++调用C中编译过的函数要加extern "C"
    linux常用指令(1)
    链式队列实现
    存储类别和类型限定词
    数组,指针和引用
    字符函数和字符串函数
    C/C++编译的程序占用的内存
    结构体1(嵌套使用)
    输入输出函数小结
  • 原文地址:https://www.cnblogs.com/Tunix/p/4303960.html
Copyright © 2020-2023  润新知