【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. ...
随机推荐
- Hadoop MapReduce编程 API入门系列之统计学生成绩版本2(十八)
不多说,直接上代码. 统计出每个年龄段的 男.女 学生的最高分 这里,为了空格符的差错,直接,我们有时候,像如下这样的来排数据. 代码 package zhouls.bigdata.myMapRedu ...
- TPL详解、使用
使用时注意点 private async void button5_Click(object sender, EventArgs e) { /* string i1 = await F1Async() ...
- RN打包的那些坑儿
Write By lz: Lz 寄语: RN虐我千百遍, 我待RN如初恋, 坑儿爬多了也就自然了 官方文档: http://reactnative.cn/docs/0.43/signed-apk-an ...
- in 与 exist , not in 与 not exist
in和exists in 是把外表和内表作hash 连接,而exists是对外表作loop循环,每次loop循环再对内表进行查询.一直以来认为exists比in效率高的说法是不准确的. 如果查询的两个 ...
- 国外60个专业3D模型网站
原始链接:http://blog.sina.com.cn/s/blog_4ba3c7950100jxkh.html Today, 3D models are used in a wide variet ...
- 考考你对java多态的理解
请看如下代码, 如果你能不运行得出正确答案, 那你真的超过99%的java程序员了. [本人属于最大头的那部分] public class A{ public String s = "A&q ...
- elasticsearch多种搜索方式
简要 1.query string search2.query DSL3.query filter4.full-text search5.phrase search6.highlight search ...
- vj线段树专题
vj线段树专题题解 单点更新模板 void build(int x,int l,int r){//sum[x]控制l-r区域 if(l==r){Sum[x]=num[l];return ;} int ...
- wamp的安装配置
WAMP是指在Windows服务器上使用Apache.MySQL和PHP的集成安装环境,可以快速安装配置Web服务器. 一.下载安装包 进入官网下载:http://www.wampserver.com ...
- [luogu3952 noip2017] 逛公园 (计数dp+最短路)
传送门 Description Input Output 输出文件包含 T 行,每行一个整数代表答案. Sample Input 2 5 7 2 10 1 2 1 2 4 0 4 5 2 2 3 2 ...