hdu-5795 A Simple Nim(组合游戏)
题目链接:
A Simple Nim
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 181 Accepted Submission(s): 119
/************************************************
┆ ┏┓ ┏┓ ┆
┆┏┛┻━━━┛┻┓ ┆
┆┃ ┃ ┆
┆┃ ━ ┃ ┆
┆┃ ┳┛ ┗┳ ┃ ┆
┆┃ ┃ ┆
┆┃ ┻ ┃ ┆
┆┗━┓ ┏━┛ ┆
┆ ┃ ┃ ┆
┆ ┃ ┗━━━┓ ┆
┆ ┃ AC代马 ┣┓┆
┆ ┃ ┏┛┆
┆ ┗┓┓┏━┳┓┏┛ ┆
┆ ┃┫┫ ┃┫┫ ┆
┆ ┗┻┛ ┗┻┛ ┆
************************************************ */ #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <stack> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
if(!p) { puts("0"); return; }
while(p) stk[++ tp] = p%10, p/=10;
while(tp) putchar(stk[tp--] + '0');
putchar('\n');
} const LL mod=1e9+7;
const double PI=acos(-1.0);
const int inf=1e9;
const int N=1e6+10;
const int maxn=2e3+14;
const double eps=1e-12;
/*
int f[110],sg[110];
inline void Init()
{
For(i,0,100)
{
mst(f,0);
For(j,1,i)
{
f[sg[i-j]]=1;
}
if(i>=3)
{
For(j,1,i-1)
For(k,1,i-1)
{
if(j+k<i)f[sg[j]^sg[k]^sg[i-j-k]]=1;
}
}
For(j,0,100)if(!f[j]){sg[i]=j;break;}
cout<<i<<" "<<sg[i]<<endl;
}
}
*/
int main()
{
//Init();
int t;
read(t);
while(t--)
{
int n,sum=0,x;
read(n);
For(i,1,n)
{
read(x);
if(x%8==7)sum^=x+1;
else if(x%8==0&&x)sum^=x-1;
else sum^=x;
}
if(sum==0)cout<<"Second player wins.\n";
else cout<<"First player wins.\n";
}
return 0;
}
hdu-5795 A Simple Nim(组合游戏)的更多相关文章
- HDU 5795 A Simple Nim(简单Nim)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- HDU 5795 A Simple Nim (博弈 打表找规律)
A Simple Nim 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5795 Description Two players take turns ...
- HDU 5795 A Simple Nim 打表求SG函数的规律
A Simple Nim Problem Description Two players take turns picking candies from n heaps,the player wh ...
- HDU 5795 A Simple Nim (博弈) ---2016杭电多校联合第六场
A Simple Nim Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- HDU 5795 A Simple Nim(SG打表找规律)
SG打表找规律 HDU 5795 题目连接 #include<iostream> #include<cstdio> #include<cmath> #include ...
- hdu 5795 A Simple Nim 博弈sg函数
A Simple Nim Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Pro ...
- HDU 5795 A Simple Nim ——(Nim博弈 + 打表)
题意:在nim游戏的规则上再增加了一条,即可以将任意一堆分为三堆都不为0的子堆也视为一次操作. 分析:打表找sg值的规律即可. 感想:又学会了一种新的方法,以后看到sg值找不出规律的,就打表即可~ 打 ...
- HDU 5795 A Simple Nim
打表找SG函数规律. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> ...
- HDU 1864 Brave Game 【组合游戏,SG函数】
简单取石子游戏,SG函数的简单应用. 有时间将Nim和.SG函数总结一下……暂且搁置. #include <cstdio> #include <cstring> #define ...
随机推荐
- jQuery与ajax的应用(一)
<body> <div id="resText"></div> <div id="reshtml"></d ...
- 七款做好DevOps的强大工具
原文链接: 7 cool tools for doing devops right 传统把开发和运营割裂开的做法,实则不适合现代产品和服务开发的需求,如今把开发和运营作为整体来看待的DevOps工程思 ...
- vs2010+qt4编译出现error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject等错误
1.当vs2010编译qt时会出现以下错误: 1>------ 已启动全部重新生成: 项目: MyDialog, 配置: Debug Win32 ------ 1>生 ...
- OpenCV视频读取播放,视频转换为图片
转载请注明出处!!! http://blog.csdn.net/zhonghuan1992 OpenCV视频读取播放,视频转换为图片 介绍几个有关视频读取的函数: VideoCapture::Vide ...
- LeetCode 之 Valid Palindrome(字符串)
[问题描写叙述] Given a string, determine if it is a palindrome, considering only alphanumeric characters a ...
- POJ 2456 Aggressive cows (二分 基础)
Aggressive cows Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7924 Accepted: 3959 D ...
- Nginx性能测试
环境:Centos 7.0 Nginx 1.6.2 测试工具:siege 3.0.7 配置1: I3-3110M 4G 测试1(100用户,1000请求): 平均响应:0.06s 并发数:59.19 ...
- 常用yum命令小结
基于rpm的软件包管理器 yum,是Yellow dog Updater, Modified的简称,是一种软件包管理器.它能够从指定的服务器自动下载RPM包并安装,可以自动处理依赖性关系,并且一次安装 ...
- SQLServer -- SQL Server Database Error: 内部 SQL Server 错误
报表在SQLserver2008运行统计正常,但是在SQLserver2000运行报错,SQL直接执行报:内部 SQL Server 错误. 不断的排查,最终得到的结论是:SQLserver2000似 ...
- IOS --支付宝SDK 分解讲解
开发在手机端的时候(客户端),我们主要负责客户端(手机端)的开发,所以那些繁琐的到支付宝官网填写商户信息可以留给后台去弄,后台只要把: 1回调地址, 2app的ID, 3商户的私钥(privateKe ...