博弈论

  Orz ZYF

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

 /**************************************************************
Problem: 3404
User: Tunix
Language: C++
Result: Accepted
Time:880 ms
Memory:5180 kb
****************************************************************/ //BZOJ 3404
#include<cstdio>
#include<iostream>
#include<algorithm>
#define F(i,j,n) for(int i=j;i<=n;++i)
using namespace std;
int getint(){
int v=,sign=; char ch=getchar();
while(!isdigit(ch)) {if(ch=='-') sign=-; ch=getchar();}
while(isdigit(ch)) {v=v*+ch-''; ch=getchar();}
return v*sign;
}
const int N=1e6+,INF=~0u>>;
/*******************template********************/
int f[N+];
int main(){
f[]=;
F(i,,N){
int x=i,mx=,mn=,t=;
while(x){ t=x%; mx=max(mx,t); if (t)mn=min(mn,t); x/=;}
if (!f[i-mx] || !f[i-mn]) f[i]=;
}
int T=getint();
while(T--)
printf( f[getint()] ? "YES\n" : "NO\n");
return ;
}

【BZOJ】【3404】【USACO2009 Open】Cow Digit Game又见数字游戏的更多相关文章

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

    一开始被题意坑了= =,题目是说这个数字的最大和最小,不是个位的最大和最小= = 不知道怎么做只能递推了,必胜态就是存在能到达必败态的,必败态就是只能到达必胜态的 CODE: #include< ...

  2. 3404: [Usaco2009 Open]Cow Digit Game又见数字游戏

    3404: [Usaco2009 Open]Cow Digit Game又见数字游戏 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 72  Solved ...

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

    http://www.lydsy.com/JudgeOnline/problem.php?id=3404 写挫好几次.... 裸的博弈论即可.. #include <cstdio> #in ...

  4. BZOJ3404: [Usaco2009 Open]Cow Digit Game又见数字游戏

    3404: [Usaco2009 Open]Cow Digit Game又见数字游戏 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 47  Solved ...

  5. 【博弈论】【SG函数】bzoj3404 [Usaco2009 Open]Cow Digit Game又见数字游戏

    #include<cstring> #include<cstdio> #include<algorithm> #include<set> using n ...

  6. BZOJ1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏

    1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 5 ...

  7. BZOJ 3403: [Usaco2009 Open]Cow Line 直线上的牛( deque )

    直接用STL的的deque就好了... ---------------------------------------------------------------------- #include& ...

  8. BZOJ 3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队 动态规划

    3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=34 ...

  9. BZOJ 3400 [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队:dp【和为f的倍数】

    题目链接:http://begin.lydsy.com/JudgeOnline/problem.php?id=1375 题意: 给你n个数,你可以从中选任意多个,但不能不选.问你所选数字之和为f的倍数 ...

随机推荐

  1. 【学习笔记】【C语言】逗号运算符

    逗号运算符主要用于连接表达式,例如: int a = 9; int b = 10; a = a+1 , b = 3*4; * 用逗号运算符连接起来的表达式称为逗号表达式,它的一般形式为: 表达式1, ...

  2. UI1_UICollectionView

    // AppDelegate.m // UI1_UICollectionView // // Created by zhangxueming on 15/7/16. // Copyright (c) ...

  3. linux 环境变量【转】

    1.引言 在 linux系统 下,如果你下载并安装了应用程序,很有可能在键入它的名称时出现" command not found "的提示内容.如果每次都到安装目标文件夹内,找到可 ...

  4. js实现移动端无限加载分页

    原理:当滚动条到达底部时,执行下一页内容. 判断条件需要理解三个概念:    1.scrollHeight 真实内容的高度    2.clientHeight 视窗的高度,即在浏览器中所能看到的内容的 ...

  5. 南阳理工oj88--汉诺塔(一)

    题目链接.http://acm.nyist.net/JudgeOnline/problem.php?pid=88 #include <stdio.h> /* //测试一下49999和500 ...

  6. 杭电ACM2092--整数解

    杭电ACM2092--整数解    分析 http://acm.hdu.edu.cn/showproblem.php?pid=2092 一个YES,一个Yes.试了10几次..我也是无语了..哪里都不 ...

  7. NOIP 2015普及组复赛Day1 T1 == Codevs4510 神奇的幻方

    时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold  题目描述 Description: 幻方是一种很神奇的N∗N矩阵:它由数字 1,2,3, … … ,N∗N构成, ...

  8. IEEE 802.15.4协议学习之MAC层

        MAC负责建立于网络的同步,支持关联和取消关联.MAC层的安全以及控制物理信道访问机制.信道访问机制主要有以下几种:       1. 有序的物理无线信道访问机制     2. 协调器启动和维 ...

  9. How to Fix Missing TortoiseSVN File Status Icons in Windows

    For many Windows-based developers, Subversion and TortoiseSVN is a great source control solution. It ...

  10. Mysql数据库常用的命令 数据备份 恢复 远程

    远程数据库 格式: mysql -h主机地址 -u用户名 -p用户密码数据库 mysql -h 42.51.150.68 -u yang -p discuz mysql设置密码 mysql>us ...