【题目链接】

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 ; }

最新文章

  1. synthesize的作用
  2. sessionPageState与视图状态存储
  3. sybase ODBC驱动
  4. 【uva】1220 Party at Hali-Bula
  5. Redis 存储、查询
  6. SoapUI进行接口测试,怎么应对接口地址总是变化!
  7. [转载] 基于Dubbo框架构建分布式服务
  8. SpringBoot开发案例之多任务并行+线程池处理
  9. SQL解决时间段重复合并问题
  10. Jenkins编辑或替换All view
  11. RHCSA之路(1) -- 重拾RHEL 7
  12. odoo生产单原材料报表
  13. WordPress 之 在注册界面 实现 注册后密码直接显示在页面上
  14. Raw Socket vs Stream Socket vs datagram socket,原始套接字与流式套接字与数据报套接字
  15. 使用markdown第一个博客
  16. 黄聪:PHP JSON_ENCODE 不转义中文汉字的方法
  17. Device Tree碎碎念
  18. php常见排序
  19. cakePHP的ajax弹出窗
  20. HDU 3970 Harmonious Set 容斥欧拉函数

热门文章

  1. JavaScript的switch循环
  2. Python 中文注释报错解决方法
  3. 快速登录MySQL数据库
  4. C# 6.0新加特性
  5. CV与IP:基础,经典以及最近发展
  6. Python中OpenCV2. VS. CV1
  7. Python快速定位工作目录
  8. 理解题意后的UVa340
  9. 应用一:Vue之开发环境搭建
  10. &lt;轉&gt;APUE:mmap函数