hdu 4664 Triangulation 博弈论。。。。我把这题称作是花样打表。。受不了了,各种坑
2015-02-28 21:25
190 查看
Triangulation
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 633 Accepted Submission(s): 248
Problem Description
There are n points in a plane, and they form a convex set.
No, you are wrong. This is not a computational geometry problem.
Carol and Dave are playing a game with this points. (Why not Alice and Bob? Well, perhaps they are bored. ) Starting from no edges, the two players play in turn by drawing one edge in each move. Carol plays first. An edge means a line segment connecting two
different points. The edges they draw cannot have common points.
To make this problem a bit easier for some of you, they are simutaneously playing on N planes. In each turn, the player select a plane and makes move in it. If a player cannot move in any of the planes, s/he loses.
Given N and all n's, determine which player will win.
Input
First line, number of test cases, T.
Following are 2*T lines. For every two lines, the first line is N; the second line contains N numbers, n1, ..., nN.
Sum of all N <= 106.
1<=ni<=109.
Output
T lines. If Carol wins the corresponding game, print 'Carol' (without quotes;) otherwise, print 'Dave' (without quotes.)
Sample Input
2 1 2 2 2 2
Sample Output
Carol Dave
这题意说的很笼统,,给你们一篇博客看吧,http://www.xuebuyuan.com/2010248.html
说的很详细的
这题的规律还真不好找,,出这题的真特么蛋疼。
前100个有几个数总是操蛋的不等于,,所以规律从后一百个找,比较方便和正确。
SG打表找规律代码(不是杭电提交代码):
#include <stdio.h> #include <string.h> #define MAX 150 int sg[MAX] ; int main() { sg[2] = 1 ; bool visited[MAX] ; for(int i = 0 ; i < MAX ; ++i) { memset(visited,false,sizeof(visited)) ; for(int j = 0 ; j <= i-2 ; ++j) { visited[sg[i-2-j]^sg[j]] = true ; } for(int j = 0 ; j <= MAX ; ++j) { if(!visited[j]) { sg[i] = j; printf("%d,",j); break ; } } } return 0 ; }
下面是我的花样打表代码(杭电提交代码):
#include <stdio.h> int sg1[]={0,0,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} ; int sg2[] = {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}; int main() { int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int ans = 0 ; for(int i = 0 ; i < n ; ++i) { int temp ; scanf("%d",&temp); if(temp>=100) { ans ^= sg2[(temp-100)%34] ; } else { ans ^= sg1[temp] ; } } if(ans) { puts("Carol") ; } else { puts("Dave"); } } return 0 ; }
与君共勉
相关文章推荐
- HDU 4664 Triangulation (SG函数,打表找规律)
- HDU-4664 Triangulation(博弈SG打表+类似凸包性质)
- hdu 3535 AreYouBusy(分组背包的变形---各种分组背包)
- hdu 3463Goldbach Division(打表法)
- hdu 4215 Number Theory?(打表)
- HDU-1012 小小的收获和对前辈的各种膜拜
- hdu 4389 囧,打表
- hdu 1431 第一次打表留念~
- hdu 3397 Sequence operation(线段树的各种操作)
- HDU 2553 N皇后问题(DFS+打表)
- hdu 3535 涵盖了分组背包的各种情况 非常好的背包题目
- HDU 1215(数论,打表 - -|)
- hdu 1215 七夕节(打表求因子和)
- HDU 2521 反素数【打表】
- hdu 1085 Humble Numbers(打表)
- hdu 3535 AreYouBusy(各种分组背包)
- http://acm.hdu.edu.cn/showproblem.php?pid=2303 (素数打表 + java大数取模)
- 09-03 HDU_Steps3.3 各种背包 HDU1114 HDU1171 HDU2191 HDU2955 HDU3496 HDU2546 HDU1203 HDU3466
- hdu 2871 Memory Control(线段树的各种操作&Splay解法)
- hdu 4389 X mod f(x) (打表)