hdu 4664 Triangulation
来源:互联网 发布:液晶电视怎样连接网络 编辑:程序博客网 时间:2024/06/06 13:52
// 题意: 给定N个平面,每个平面有ni个点
// ni个点组成一个凸多边形
//
// 然后在N个平面上进行游戏,每次选取一个平面进行
// 在每个平面上可以选择两个点链接一条直线
// 每次选择的点连线不能和已经有的直线相交
// 思路:根据SG定理
// 可以先求出一个平面的SG值,在对所有的平面的SG 值进行异或
// 那么一个平面的SG值
// 由于是凸多边形
// 那么只要连接两个点就把一个凸多边形分成了两个子多边形
// 并且边界上的两个点是不能再选的
// 就相当于在两个子平面上进行游戏了
// 因为两边的点一定不能连一条线,会与已经的直线相交
// 所以SG[x]=mex{SG[i]^SG[x-i-2]};
// 打表之后可以发现每102项是重复的
// 好吧其实是34项重复的
// 但是前面的是不重复的
// author:latstars// time:20160909 20:30// Problem:hdu 4664 Triangulation// 分类:数学,SG函数,打表找规律#include<cstdio>#include<cstring>#include<algorithm>using namespace std;typedef long long LL;const int maxn=400+10;const int maxN=1000000;bool vis[maxn];int sg[maxn];int SG(int x){ if(x<=102){ return sg[x]; } else{ return sg[x%102+102]; }}void solve(){ memset(sg,0,sizeof(sg)); sg[0]=sg[1]=0; sg[2]=1; for(int i=3;i<=maxn-1;i++){ memset(vis,0,sizeof(vis)); for(int j=0;j<=i&&(i-j-2)>=0;j++){ vis[sg[j]^sg[i-j-2]]=1; } for(int j=0;1;j++){ if(!vis[j]){ sg[i]=j; break; } } }/* for(int i=1;i<=maxn-1;i++){ printf("%d ",sg[i]); if(i%102==0) puts(""); }*/}int T,N;int a;int main(){ solve(); scanf("%d",&T); while(T--){ scanf("%d",&N); int res=0; for(int i=1;i<=N;i++){ scanf("%d",&a); res=(res^SG(a)); } if(res) puts("Carol"); else puts("Dave"); } return 0;}// print pre 102 // except the first 102line // next 102 cycle/*http://acm.split.hdu.edu.cn/showproblem.php?pid=46640 1 1 2 0 3 1 1 0 3 3 2 2 4 0 5 2 2 3 3 0 1 1 3 0 2 1 1 0 4 5 2 7 4 0 1 1 2 0 3 1 1 0 3 3 2 2 4 4 5 5 2 3 3 0 1 1 3 0 2 1 1 0 4 5 3 7 4 8 1 1 2 0 3 1 1 0 3 3 2 2 4 4 5 5 9 3 3 0 1 1 3 0 2 1 1 0 4 5 3 7 4 8 1 1 2 0 3 1 1 0 3 3 2 2 4 4 5 5 9 3 3 0 1 1 3 0 2 1 1 0 4 5 3 7 4 8 1 1 2 0 3 1 1 0 3 3 2 2 4 4 5 5 9 3 3 0 1 1 3 0 2 1 1 0 4 5 3 7 4 8 1 1 2 0 3 1 1 0 3 3 2 2 4 4 5 5 9 3 3 0 1 1 3 0 2 1 1 0 4 5 3 7 4 8 1 1 2 0 3 1 1 0 3 3 2 2 4 4 5 5 9 3 3 0 1 1 3 0 2 1 1 0 4 5 3 7 4 8 1 1 2 0 3 1 1 0 3 3 2 2 4 4 5 5 9 3 3 0 1 1 3 0 2 1 1 0 4 5 3 7 4 8 1 1 2 0 3 1 1 0 3 3 2 2 4 4 5 5 9 3 3 0 1 1 3 0 2 1 1 0 4 5 3 7 4 8 1 1 2 0 3 1 1 0 3 3 2 2 4 4 5 5 9 3 3 0 1 1 3 0 2 1 1 0 4 5 3 7 4 8 1 1 2 0 3 1 1 0 3 3 2 2 4 4 5 5 9 3 3 0 1 1 3 0 2 1 1 0 4 5 3 7 4 8 1 1 2 0 3 1 1 0 3 3 2 2 4 4 5 5 9 3 3 0 1 1 3 0 2 1 1 0 4 5 3 7 4 */
0 0
- hdu 4664Triangulation
- HDU 4664 Triangulation【博弈论】
- hdu 4664 Triangulation
- hdu - 4664 - Triangulation(博弈SG)
- SG函数 hdu 4664 Triangulation
- hdu 4664 Triangulation 经典博弈
- hdu 4664 Triangulation(博弈)
- HDU 4664 Triangulation-SG函数
- hdu 1966 Minimax Triangulation
- hdu 4664 Triangulation(博弈论 sg找规律打表)
- HDU 4664 Triangulation (SG函数,打表找规律)
- hdu 4664 Triangulation/杭电多校2013第六场1010, SG定理+找规律
- 2013 多校第六场 hdu 4664 Triangulation(SG问题)
- HDU-4664 Triangulation(博弈SG打表+类似凸包性质)
- 2017hdu沈阳网络赛补题triangulation
- hdu 4664 Triangulation 博弈论。。。。我把这题称作是花样打表。。受不了了,各种坑
- hdu 1966 /poj 2066 Minimax Triangulation 计算几何
- Delaunay triangulation
- Ubuntu16.04下安装ns2.35
- Hust oj 1629 统计图(水题)
- OSGI 框架搭建
- Hibernate使用注解配置映射
- 剑指offer[8]变态跳台阶
- hdu 4664 Triangulation
- Android中Bitmap的分析与使用
- HDU5444(2015长春网赛)——Elven Postman(树的遍历,dfs)
- android stadio svn 使用技巧
- unix和dos文本文件的区别
- Java同步机制
- beego 注解路由
- 跟我一起学python(一),python基础
- AL笔试