【题目链接】

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的更多相关文章

  1. bzoj 2295: 【POJ Challenge】我爱你啊

    2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec  Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...

  2. 【链表】BZOJ 2288: 【POJ Challenge】生日礼物

    2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 382  Solved: 111[Submit][S ...

  3. BZOJ2288: 【POJ Challenge】生日礼物

    2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 284  Solved: 82[Submit][St ...

  4. BZOJ2293: 【POJ Challenge】吉他英雄

    2293: [POJ Challenge]吉他英雄 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 80  Solved: 59[Submit][Stat ...

  5. BZOJ2287: 【POJ Challenge】消失之物

    2287: [POJ Challenge]消失之物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 254  Solved: 140[Submit][S ...

  6. BZOJ2295: 【POJ Challenge】我爱你啊

    2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 126  Solved: 90[Submit][Sta ...

  7. BZOJ2296: 【POJ Challenge】随机种子

    2296: [POJ Challenge]随机种子 Time Limit: 1 Sec  Memory Limit: 128 MBSec  Special JudgeSubmit: 114  Solv ...

  8. BZOJ2292: 【POJ Challenge 】永远挑战

    2292: [POJ Challenge ]永远挑战 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 513  Solved: 201[Submit][ ...

  9. 【POJ 1125】Stockbroker Grapevine

    id=1125">[POJ 1125]Stockbroker Grapevine 最短路 只是这题数据非常水. . 主要想大牛们试试南阳OJ同题 链接例如以下: http://acm. ...

随机推荐

  1. CI中的文件上传

    //首先在控制器中装载url类和view视图: //在view视图中创建一个表单,注:在做文件上传一定要写encype=“multipart/form-data”: //form表单的提交页面应该使用 ...

  2. Codeforces Round #454

    Masha and Bears Tic-Tac-Toe Shockers Seating of Students Party Power Tower Reverses

  3. in 与 exist , not in 与 not exist

    in和exists in 是把外表和内表作hash 连接,而exists是对外表作loop循环,每次loop循环再对内表进行查询.一直以来认为exists比in效率高的说法是不准确的. 如果查询的两个 ...

  4. aspnet_regiis加密文件提示路径中具有非法字符

    加密结果受当前目录影响,不知道是不是哪里操作错误,mark.   Web.config文件位置:E:\Web\Surgery 加密成功,上图命令最后有个".",表示web.conf ...

  5. (转) shiro权限框架详解06-shiro与web项目整合(上)

    http://blog.csdn.net/facekbook/article/details/54947730 shiro和web项目整合,实现类似真实项目的应用 本文中使用的项目架构是springM ...

  6. 优动漫PAINT动画创作功能介绍

    优动漫PAINT也就是我们常说的clip studio paint(CSP)的中文版本,它是一款功能强大的漫画.插画绘制软件,它搭载了绘制漫画和插画所需的所有功能,包括丰富的笔工具.超强的笔压感应和手 ...

  7. MongoDB 学习笔记(四):索引

    一.索引的基本使用 1.建立索引 在shell中为某个key建立索引的方法为:db.集合名.ensureIndex({key:1}),其中的key表示为哪个key建立索引,1表示升序建立索引,而-1表 ...

  8. new String(getBytes(ISO-8859-1),UTF-8)中文编码避免乱码

    byte[] b_gbk = "深".getBytes("GBK"); byte[] b_utf8 = "深".getBytes(" ...

  9. vc++元文件的保存,保存图形,重绘图形

    1, CMateFileDC 可以用来多次打开自己的画布,这个元文件包含许多接口的命令 当绘制好之后可以用来播放元文件 首先,创建一个CMateFileDC的元文件对象 然后调用Create原函数,创 ...

  10. Javascript中的null和 undefined

    Javascript Undefined vs NULL Many a times we often get confused on whats the difference between UNDE ...