LuoguP2953 [USACO09OPEN]牛的数字游戏Cow Digit Game(博弈论)
1~9显然,后面平\(A\)过去
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define R(a,b,c) for(register int a = (b); a <= (c); ++a)
#define nR(a,b,c) for(register int a = (b); a >= (c); --a)
#define Fill(a,b) memset(a, b, sizeof(a))
#define Swap(a,b) ((a) ^= (b) ^= (a) ^= (b))
#define ON_DEBUGG
#ifdef ON_DEBUGG
#define D_e_Line printf("-----------\n")
#define D_e(x) std::cout << (#x) << " : " <<x << "\n"
#define FileOpen() freopen("in.txt", "r", stdin)
#define FileSave() freopen("out2.txt", "w", stdout)
#define Pause() system("pause")
#include <ctime>
#define TIME() fprintf(stderr, "\nTIME : %.3lfms\n", clock() * 1000.0 / CLOCKS_PER_SEC)
#else
#define D_e_Line ;
#define D_e(x) ;
#define FileOpen() ;
#define FilSave ;
#define Pause() ;
#define TIME() ;
#endif
struct ios {
template<typename ATP> ios& operator >> (ATP &x) {
x = 0; int f = 1; char c;
for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-') f = -1;
while(c >= '0' && c <= '9') x = x * 10 + (c ^ '0'), c = getchar();
x *= f;
return *this;
}
}io;
using namespace std;
template<typename ATP> inline ATP Min(ATP a, ATP b) {
return a < b ? a : b;
}
template<typename ATP> inline ATP Max(ATP a, ATP b) {
return a > b ? a : b;
}
template<typename ATP> inline ATP Abs(ATP a) {
return a < 0 ? -a : a;
}
const int N = 1000007;
int maxx, minn;
inline void Calc(int n) {
while(n){
int tmp = n % 10;
maxx = Max(maxx, tmp);
if(tmp) minn = Min(minn, tmp);
n /= 10;
}
}
int f[N];
int main() {
R(i,1,9) f[i] = true;
R(i,10,N - 5){
maxx = 0, minn = 10;
Calc(i);
if(!(f[i - maxx] && f[i - minn]))
f[i] = true;
}
int Tasks;
io >> Tasks;
while(Tasks--){
int n;
io >> n;
if(f[n])
printf("YES\n");
else
printf("NO\n");
}
return 0;
}

LuoguP2953 [USACO09OPEN]牛的数字游戏Cow Digit Game(博弈论)的更多相关文章
- 洛谷 2953 [USACO09OPEN]牛的数字游戏Cow Digit Game
洛谷 2953 [USACO09OPEN]牛的数字游戏Cow Digit Game 题目描述 Bessie is playing a number game against Farmer John, ...
- [USACO09OPEN]牛的数字游戏Cow Digit Game 博弈
题目描述 Bessie is playing a number game against Farmer John, and she wants you to help her achieve vict ...
- 【Luogu】P2953牛的数字游戏(博弈论)
题目链接 自己乱搞……然后一遍AC啦! 思路从基本的必胜态和必败态开始分析.我们把减去最大数得到的数叫作Max,减去最小数得到的数叫作Min. 那么开始分析. 一.0是必败态. 这个没法解释.题目就这 ...
- 洛谷 [P2953] 牛的数字游戏
SG搜索 n的范围在可以接受的范围内,SG搜索即可 #include <iostream> #include <cstdio> #include <cstring> ...
- BZOJ3404: [Usaco2009 Open]Cow Digit Game又见数字游戏
3404: [Usaco2009 Open]Cow Digit Game又见数字游戏 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 47 Solved ...
- 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又见数字游戏(博弈论)
http://www.lydsy.com/JudgeOnline/problem.php?id=3404 写挫好几次.... 裸的博弈论即可.. #include <cstdio> #in ...
- 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 奶牛的数字游戏
Description 奶牛们又在玩一种无聊的数字游戏.输得很郁闷的贝茜想请你写个程序来帮她在开局时预测结果.在游戏的开始,每头牛都会得到一个数N(1<=N<=1,000,000).此时奶 ...
随机推荐
- C++:制作火把
制作火把 时间限制 : 1.000 sec 内存限制 : 128 MB 题目描述: 小红最近在玩一个制作火把的游戏,一开始,小红手里有一根木棍,她希望能够通过这一根木棍通过交易换取制 ...
- MIT 6.824(Spring 2020) Lab1: MapReduce 文档翻译
首发于公众号:努力学习的阿新 前言 大家好,这里是阿新. MIT 6.824 是麻省理工大学开设的一门关于分布式系统的明星课程,共包含四个配套实验,实验的含金量很高,十分适合作为校招生的项目经历,在文 ...
- 2021.05.04【NOIP提高B组】模拟 总结
T1 题目大意, \(S_{i,j}=\sum_{k=i}^j a_k\) ,求 \(ans=\min\{ S_{i,j}\mod P|S_{i,j}\mod P\ge K \}\) 其中 \(i\l ...
- 1.3 操作系统的第三个功能——存储管理功能 -《zobolの操作系统学习札记》
1.3 操作系统的第三个功能--存储管理功能 作者zobol:关于操作系统概论-存储管理功能,我给出下列问题: 目录 1.3 操作系统的第三个功能--存储管理功能 问1:操作系统的文件管理系统主要是负 ...
- 『忘了再学』Shell流程控制 — 38、while循环和until循环介绍
目录 1.while循环 2.until循环 1.while循环 对while循环来讲,只要条件判断式成立,循环就会一直继续,直到条件判断式不成立,循环才会停止.和for循环的第二种格式for((初始 ...
- SAP setting and releasing locks
REPORT demo_transaction_enqueue MESSAGE-ID sabapdocu. TABLES sflight. DATA text(8) TYPE c. DATA ok_c ...
- SAP 隐式增强 Enhancement point
1.进入编辑器:SE38/SE37/SE24 Edit-->Enhancement Operations-->Create Option 2.填写相关信息,点击对号. 3.点击Enhanc ...
- 端口被占用的问题解决 Web server failed to start. Port ×× was already in use
出现此问题是端口被占用了,只需要关闭正在使用的端口就行 解决思路: 1.在服务器中更改port端口号,改为不冲突,没有被占用的端口. 2.找出被占用的端口,结束被占用的端口 解决结束被占用的端口的方法 ...
- 手把手教你用 Python 下载手机小视频
今天为大家介绍使用 mitmproxy 这个抓包工具如何监控手机上网,并且通过抓包,把我们想要的数据下载下来. 启动 mitmproxy 首先我们通过执行命令 mitmweb 启动mitmproxy, ...
- STC8H开发(十二): I2C驱动AT24C08,AT24C32系列EEPROM存储
目录 STC8H开发(一): 在Keil5中配置和使用FwLib_STC8封装库(图文详解) STC8H开发(二): 在Linux VSCode中配置和使用FwLib_STC8封装库(图文详解) ST ...