hdu 4664 Triangulation(博弈)
来源:互联网 发布:hive sql 编辑:程序博客网 时间:2024/06/17 23:11
题目链接:hdu 4664 Triangulation
解题思路
根据SG定理打个表,SG值最多为9,前几项在SG值不全的时候没有规律,但是当SG值为9的出现后,以34为一循环。
代码
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int sg[] = {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};const int cir[] = {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};int SG (int x) { if (x < 69) return sg[x]; x %= 34; return cir[x];}int main() { int cas; scanf("%d", &cas); while (cas--) { int n, x, s = 0; scanf("%d", &n); while (n--) { scanf("%d", &x); s ^= SG(x); } printf("%s\n", s ? "Carol" : "Dave"); } return 0;}
0 0
- hdu 4664 Triangulation(博弈)
- hdu - 4664 - Triangulation(博弈SG)
- hdu 4664 Triangulation 经典博弈
- hdu 4664Triangulation
- HDU 4664 Triangulation【博弈论】
- hdu 4664 Triangulation
- HDU-4664 Triangulation(博弈SG打表+类似凸包性质)
- SG函数 hdu 4664 Triangulation
- HDU 4664 Triangulation-SG函数
- hdu 4664 Triangulation(博弈论 sg找规律打表)
- HDU 4664 Triangulation (SG函数,打表找规律)
- 2013 多校第六场 hdu 4664 Triangulation(SG问题)
- hdu 1966 Minimax Triangulation
- 三角测量(triangulation)
- hdu 2149 (博弈)
- hdu 1079(博弈)
- hdu 1517 (博弈)
- hdu 4642 (博弈)
- 深入浅出 React Native:使用 JavaScript 构建原生应用
- android4.3-android4.4.2触摸唤醒
- 指针、数组
- hello world
- 去掉 WordPress 3.1+版本顶部的admin bar管理工具
- hdu 4664 Triangulation(博弈)
- Matlab “Out of memory”解决办法
- android基础之ADB常用命令
- Android中的webview详细使用
- LeetCode16:3Sum Closest
- 计算机原理之c语言实现链表
- hdu 4665 Unshuffle(暴力)
- On Hat Puzzle 2.1: From Dr. Todd Ebert's thesis
- Linux下载安装sshd服务,用SecureCRT连接虚拟机