hdu3032sg打表找规律
先打个表冷静一下
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=,inf=; int f[N],sg[N],Hash[N];//f是可以取走的石子书
void getsg(int n)
{
memset(Hash,,sizeof Hash);
for(int i=;i<n;i++)
Hash[sg[i]]=;
for(int i=;i<=n;i++)
for(int j=;j<=n;j++)
if(i+j==n)
Hash[sg[i]^sg[j]]=;
for(int i=;;i++)
if(!Hash[i])
{
sg[n]=i;
break;
}
cout<<n<<" "<<sg[n]<<endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie();
for(int i=;i<=;i++)
getsg(i);
return ;
}
可以看出sg【i】=i;i%4==1||2
sg[i]=i+1,i%4==3
sg[i]=i-1,i%4==4
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=,inf=; int main()
{
ios::sync_with_stdio(false);
cin.tie();
int t,n,a;
cin>>t;
while(t--){
cin>>n;
int ans;
for(int i=;i<n;i++)
{
cin>>a;
if(a%==)a++;
else if(a%==)a--;
if(i==)ans=a;
else ans=ans^a;
}
if(!ans)cout<<"Bob"<<endl;
else cout<<"Alice"<<endl;
}
return ;
}
hdu3032sg打表找规律的更多相关文章
- hdu 3032 Nim or not Nim? (SG函数博弈+打表找规律)
Nim or not Nim? Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Sub ...
- HDU 5753 Permutation Bo (推导 or 打表找规律)
Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...
- HDU 4861 Couple doubi (数论 or 打表找规律)
Couple doubi 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/D Description DouBiXp has a ...
- HDU2149-Good Luck in CET-4 Everybody!(博弈,打表找规律)
Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...
- 【ZOJ】3785 What day is that day? ——浅谈KMP在ACM竞赛中的暴力打表找规律中的应用
转载请声明出处:http://www.cnblogs.com/kevince/p/3887827.html ——By Kevince 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这 ...
- HDU 5795 A Simple Nim(SG打表找规律)
SG打表找规律 HDU 5795 题目连接 #include<iostream> #include<cstdio> #include<cmath> #include ...
- hdu_5894_hannnnah_j’s Biological Test(打表找规律)
题目链接:hdu_5894_hannnnah_j’s Biological Test 题意: 有n个不同的位置围成一个圈,现在要安排m个人坐,每个人至少的间隔为k,问有多少种安排 题解: 先打表找规律 ...
- hdu_5795_A Simple Nim(打表找规律的博弈)
题目链接:hdu_5795_A Simple Nim 题意: 有N堆石子,你可以取每堆的1-m个,也可以将这堆石子分成3堆,问你先手输还是赢 题解: 打表找规律可得: sg[0]=0 当x=8k+7时 ...
- hdu_5793_A Boring Question(打表找规律)
题目链接:hdu_5793_A Boring Question 题意: 自己看吧,说不清楚了. 题解: 打表找规律 #include<cstdio> typedef long long l ...
随机推荐
- Cisco设备开启telnet登录
思科设备怎么开启telnet登录 configuration line vty 0 4SW1(config-line)#transp input telne
- slave have equal MySQL Server UUIDs原因及解决
最近在部署MySQL主从复制架构的时候,碰到了"Last_IO_Error: Fatal error: The slave I/O thread stops because master a ...
- mybatis-spring-boot-autoconfigure
mybatis-spring-boot-autoconfigure – MyBatis Sring-BootStarter | Reference Documentation http://www.m ...
- spring boot web服务
[root@d java]# tree -I target .├── pom.xml└── src ├── main │ ├── java │ │ └── com │ │ └── ...
- Python开发【模块】:re正则
re模块 序言: re模块用于对python的正则表达式的操作 '.' 默认匹配除\n之外的任意一个字符,若指定flag DOTALL,则匹配任意字符,包括换行 '^' 匹配字符开头,若指定flags ...
- EOS Dapp开发(1)-基于Docker的开发环境搭建
随着EOS主网的上线,相信基于EOS的Dapp开发会越来越多,查阅了很多资料相关的开发资料都不是很多,只能自己摸索,按照网上仅有的几篇教程,先git clonehttps://github.com/E ...
- Maven的pom文件配置
pom.xml文件如下: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http:// ...
- 很靠谱linux常用命令
vim是打开vim编辑器,别的编辑器还有vi(功能没有vim 强大),nano,emacs等等,感觉还是vim最强大,其次是vi,别的就要差一些了. 我听我们老师说,用图形界面本身已经会被高手笑了,如 ...
- Docker Compose 入门使用指南
Compose is a tool for defining and running multi-container Docker applications. With Compose, you us ...
- (26)SQLite集成与用法
概述 在Cocos2d-x中,简单数据存储,可以使用UserDefault.那么如何存储大量,不规则的数据?我们可以使用SQLite数据库存储数据.SQLite是使用非常广泛的嵌入式数据库,它有小巧 ...