BZOJ3404: [Usaco2009 Open]Cow Digit Game又见数字游戏
3404: [Usaco2009 Open]Cow Digit Game又见数字游戏
Time Limit: 3 Sec Memory Limit: 128 MB
Submit: 47 Solved: 32
[Submit][Status]
Description
Input
Output
Sample Input
9
10
Sample Output
NO
HINT
For the first game, Bessie simply takes the number 9 and wins.
For the second game, Bessie must take 1 (since she cannot take 0), and then
FJ can win by taking 9.
Source
题解:
把sg函数都预处理出来。。。
代码:
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 1000000+5
#define maxm 500+100
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define mod 1000000007
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}
return x*f;
}
bool f[maxn];
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
f[]=;
for1(i,maxn)
{
int x=i,t,mi=,mx=;
while(x){t=x%;mx=max(mx,t);if(t)mi=min(mi,t);x/=;}
if(!f[i-mi]||!f[i-mx])f[i]=;
}
int cs=read();
while(cs--)
if(f[read()])printf("YES\n");else printf("NO\n");
return ;
}
BZOJ3404: [Usaco2009 Open]Cow Digit Game又见数字游戏的更多相关文章
- 【博弈论】【SG函数】bzoj3404 [Usaco2009 Open]Cow Digit Game又见数字游戏
#include<cstring> #include<cstdio> #include<algorithm> #include<set> using n ...
- 3404: [Usaco2009 Open]Cow Digit Game又见数字游戏
3404: [Usaco2009 Open]Cow Digit Game又见数字游戏 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 72 Solved ...
- BZOJ 3404: [Usaco2009 Open]Cow Digit Game又见数字游戏(博弈论)
一开始被题意坑了= =,题目是说这个数字的最大和最小,不是个位的最大和最小= = 不知道怎么做只能递推了,必胜态就是存在能到达必败态的,必败态就是只能到达必胜态的 CODE: #include< ...
- 【BZOJ】3404: [Usaco2009 Open]Cow Digit Game又见数字游戏(博弈论)
http://www.lydsy.com/JudgeOnline/problem.php?id=3404 写挫好几次.... 裸的博弈论即可.. #include <cstdio> #in ...
- 【BZOJ】【3404】【USACO2009 Open】Cow Digit Game又见数字游戏
博弈论 Orz ZYF 从前往后递推……反正最大才10^6,完全可以暴力预处理每个数的状态是必胜还是必败(反正才两个后继状态),然后O(1)查询……我是SB /******************** ...
- BZOJ1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 5 ...
- 【BZOJ】1666 [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
[算法]贪心&&堆 [题解]反过来看就是合并任意两块木板,花费为木板长度之和. 显然从最小的两块开始合并即可,用堆(优先队列)维护. 经典DP问题石子归并是只能合并相邻两堆石子,所以不 ...
- bzoj:1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
Description 奶牛们又在玩一种无聊的数字游戏.输得很郁闷的贝茜想请你写个程序来帮她在开局时预测结果.在游戏的开始,每头牛都会得到一个数N(1<=N<=1,000,000).此时奶 ...
- 【BZOJ】1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏(刷水严重)
http://www.lydsy.com/JudgeOnline/problem.php?id=1666 这种我就不说了.. #include <cstdio> #include < ...
随机推荐
- SAX - Hello World
SAX 是一种事件驱动的 XML 数据处理模型.对于 DOM 模型,解析 XML 文档时,需要将所有内容载入内容.相比 DOM 模型,SAX 模型更为高效,它一边扫描一边解析 XML 文档.但与 DO ...
- HttpClient(4.3.5) - HTTP Protocol Interceptors
The HTTP protocol interceptor is a routine that implements a specific aspect of the HTTP protocol. U ...
- Redis 命令 - Transactions
DISCARD Discard all commands issued after MULTI 127.0.0.1:6379> MGET bank:A:account bank:B:accoun ...
- Agile.Net 组件式开发平台 - 组件开发示例
所谓组件式开发平台,它所有的功能模块都是以组件的形式扩展的,下面我来演示一个简单的组件开发例程. Agile.Net开发管理平台项目,已经托管在开源中国码云平台(http://git.oschina. ...
- 给 Android 初学者的 Gradle 知识普及
给 Android 初学者的 Gradle 知识普及:http://gold.xitu.io/entry/5778f8bd165abd0054b443b0/promote?utm_source=bai ...
- ssh git设置命令行
#列出key ls -al ~/.ssh #生成key ssh-keygen -t rsa -b -C "your_email@example.com" #判断ssh-agent可 ...
- struts2文件上传(保存为BLOB格式)
html文件:提供上传文件的入口 <input type="file" name="upload"><!-- name很重要,与后面actio ...
- 资源汇集:nginx教程从入门到精通
http://linux.cn/article-4279-1.html
- iOS动画——弹窗动画(pop动画)
用pop动画简单实现弹窗的缩放和渐变,感觉这个动画常用,就写一下博客 pop动画是Facebook推出的动画引擎,请自行到GitHub上搜索下载拖拽导入xcode项目中. 更多pop动画使用和原理可网 ...
- linux端口与进程命令
1 lsof命令 lsof -i:portNum 查出来与该端口相关的所有程序 2 netstat命令: netstat -lnp