hdu 5795
A Simple Nim
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 948 Accepted Submission(s): 559
players take turns picking candies from n heaps,the player who picks
the last one will win the game.On each turn they can pick any number of
candies which come from the same heap(picking no candy is not
allowed).To make the game more interesting,players can separate one heap
into three smaller heaps(no empty heaps)instead of the picking
operation.Please find out which player will win the game if each of them
never make mistakes.
the number of test cases. Each case begins with an integer n,
indicating the number of the heaps, the next line contains N integers s[0],s[1],....,s[n−1], representing heaps with s[0],s[1],...,s[n−1] objects respectively.(1≤n≤106,1≤s[i]≤109)
2
4 4
3
1 2 4
First player wins.
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int visited[];
int sg[];
int main(){
/*int i,j,k;
for(i=1;i<40;i++){
memset(visited,0,sizeof(visited));
for(j=0;j<i;j++)visited[sg[j]]=1;
for(j=1;j<i;j++){
for(k=1;k+j<i;k++){
visited[sg[j]^sg[k]^sg[i-k-j]]=1;
}
}
for(j=0;j<40;j++){
if(visited[j]==0){
break;
}
}
sg[i]=j;
}
for(i=1;i<40;i++){
cout<<i<<" "<<sg[i]<<endl;
}*/
int t;
scanf("%d",&t);
int n,i,x;
int ans;
while(t--){
scanf("%d",&n);
ans=;
for(i=;i<n;i++){
scanf("%d",&x);
if(x%==){
x=x-;
ans=ans^x;
}
else if(x%==){
x=x+;
ans=ans^x;
}
else
ans=ans^x; }
cout<<ans<<endl;
}
}
hdu 5795的更多相关文章
- 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(SG打表找规律)
SG打表找规律 HDU 5795 题目连接 #include<iostream> #include<cstdio> #include<cmath> #include ...
- HDU 5795:A Simple Nim(博弈)
http://acm.hdu.edu.cn/showproblem.php?pid=5795 A Simple Nim Problem Description Two players take t ...
- HDU 5795 博弈
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5795 A Simple Nim Time Limit: 2000/1000 MS (Java/Oth ...
- 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函数规律. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> ...
- hdu 5795 A Simple Nim 博弈sg函数
A Simple Nim Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Pro ...
随机推荐
- Modelica学习
Annotation Choices for Suggested Redeclarations and Modifications Replaceable model sample(start,int ...
- APS.net controller
在controller 路由配置为: routes.MapRoute( name:"Default", url:"{controller}/{action}/{id}&q ...
- 【转】NVelocity模板引擎初学总结
转自:http://sunxitao88.blog.163.com/blog/static/68314439200861963326251/ 前不久,接触到.NET下的MVC-MonoRail,它推荐 ...
- 循序渐进Python3(十一) --2-- web之javascript
JavaScrip JavaScript是一门编程语言,浏览器内置了JavaScript语言的解释器,所以在浏览器上按照JavaScript语言的规则编写相应代码之后 ...
- JavaScript学习(一)—处理事件2
下面的表中为最常用的 12 种 JavaScript 事件处理程序. 一.处理窗口事件(onload事件,onunload事件,onresize事件,onmove事件,onabort事件,onerro ...
- CSS3转换
一.2D转换 1.css3 rotate()旋转 通过指定的角度参数对原元素指定一个2D rotation(2D 旋转) 语法: transform:rotate(<angle>); ...
- Xcode8 安装插件
关闭Xcode 一.进入https://github.com/inket/update_xcode_plugins下载 二.打开终端,输入sudo gem install update_xcode_p ...
- 怎样从altera下载软件与器件库
首先要注册一个帐号,否则是不能下载的. step1:进入support->download 这是页面下方的显示,可以选择想要安装的Quartus版本以及该版本支持的器件.这里以16.0标准版为例 ...
- div里面的id与for
<input class="select" type="checkbox" value="1" id="checkboxjc ...
- 自定义UISearchBar
先上系统默认的UISearchBar,然后用KVO修改 UISearchBar *searchBar = [[UISearchBar alloc]initWithFrame:_topView.boun ...