【POJ 2311】 Cutting Game
【题目链接】
http://poj.org/problem?id=2311
【算法】
博弈论——SG函数
【代码】
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <stack>
#include <limits.h>
using namespace std;
#define MAXN 210 int n,m;
int sg[MAXN][MAXN]; inline int getSG(int n,int m)
{
int i;
bool s[];
if (sg[n][m] != -) return sg[n][m];
memset(s,false,sizeof(s));
for (i = ; i <= n - ; i++) s[getSG(n-i,m)^getSG(i,m)] = true;
for (i = ; i <= m - ; i++) s[getSG(n,i)^getSG(n,m-i)] = true;
for (i = ; ; i++)
{
if (!s[i])
return sg[n][m] = i;
}
} int main()
{ memset(sg,,sizeof(sg));
while (scanf("%d%d",&n,&m) != EOF)
{
printf(getSG(n,m)?"WIN\n":"LOSE\n");
} return ; }
【POJ 2311】 Cutting Game的更多相关文章
- bzoj 2295: 【POJ Challenge】我爱你啊
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...
- 【链表】BZOJ 2288: 【POJ Challenge】生日礼物
2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 382 Solved: 111[Submit][S ...
- BZOJ2288: 【POJ Challenge】生日礼物
2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 284 Solved: 82[Submit][St ...
- BZOJ2293: 【POJ Challenge】吉他英雄
2293: [POJ Challenge]吉他英雄 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 80 Solved: 59[Submit][Stat ...
- BZOJ2287: 【POJ Challenge】消失之物
2287: [POJ Challenge]消失之物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 254 Solved: 140[Submit][S ...
- BZOJ2295: 【POJ Challenge】我爱你啊
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 126 Solved: 90[Submit][Sta ...
- BZOJ2296: 【POJ Challenge】随机种子
2296: [POJ Challenge]随机种子 Time Limit: 1 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 114 Solv ...
- BZOJ2292: 【POJ Challenge 】永远挑战
2292: [POJ Challenge ]永远挑战 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 513 Solved: 201[Submit][ ...
- 【POJ 1125】Stockbroker Grapevine
id=1125">[POJ 1125]Stockbroker Grapevine 最短路 只是这题数据非常水. . 主要想大牛们试试南阳OJ同题 链接例如以下: http://acm. ...
随机推荐
- IE不支持 ES6 Promise 对象的解决方案
* 引入bluebird.js即可完美解决. /*ie兼容 Promise*/ isIE(); function isIE() { //ie? if ( !! window.ActiveXObject ...
- intelij idea+springMVC+spring+mybatis 初探(持续更新)
intelij idea+springMVC+spring+mybatis 初探(持续更新) intellij 创建java web项目(maven管理的SSH) http://blog.csdn.n ...
- [C]关于交换
交换(c,c++): 1)temp交换(也适用于非数型) 定义一个新的变量,借助它完成交换. int a,b; a=10; b=15; int t; t=a; a=b; b=t; 2)位运算 位运算不 ...
- 记一个男默女泪的 BUG
姗姗来迟的词频统计代码 BUG 的发现 1. 此前提交的第一次代码作业总结博客 http://www.cnblogs.com/ustczwq/p/8680704.html 2. BUG 本天成,妙手偶 ...
- linq.sort
reflections.Sort(delegate(ReflectionEntity a, ReflectionEntity b) { if (a.CreatedTime < b.Created ...
- Http状态码大全(200、404、500等)
基本涵盖了所有问题 HTTP 400 – 请求无效HTTP 401.1 – 未授权:登录失败HTTP 401.2 – 未授权:服务器配置问题导致登录失败HTTP 401.3 – ACL 禁止访问资源H ...
- Eigen库对齐问题:declspec(align('16')) 的形参将不被对齐
一:错误提示:error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned 英文提示:erro ...
- CDR案例:广告条幅banner设计
本教程练习使用裁剪.位图.变换.阴影.透明度等特殊效果等工具制作广告条幅banner,具体操作如下. 1. 执行“文件”→“新建”命令,打开“创建新文档”对话框,在“宽度”选框右侧选择单位为“像素”, ...
- setTimeout()传带有参数的函数
w3cshool里的解释:setTimeout() 方法用于在指定的毫秒数后调用函数或计算表达式,语法:setTimeout(code,millisec). 也就是说,第一个参数可以是字符串形式的Ja ...
- gitlab安装和汉化
Centos 7.x 安装 gitlab-ce-8.8.0-ce 一.安装配置依赖项 yum -y install curl unzip policycoreutils git wget # 依赖包 ...