ZOJ 2083 SG函数
来源:互联网 发布:淘宝可靠的正品美瞳店 编辑:程序博客网 时间:2024/06/03 21:58
SG函数的题目
初始化计算sg函数时 temp = sg[j] ^ sg[i - j - 2]; 然后查找sg值异或即可
第一个1A的sg函数题目
#include <set>#include <cmath>#include <queue>#include <stack>#include <string>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long LL;const double PI = acos(-1.0);template <class T> inline T MAX(T a, T b){if (a > b) return a;return b;}template <class T> inline T MIN(T a, T b){if (a < b) return a;return b;}const int N = 111;const int M = 11111;const LL MOD = 1000000007LL;const int dir[4][2] = {1, 0, -1, 0, 0, -1, 0, 1};const int INF = 0x3f3f3f3f;int sg[55];void initsg(){int i, j, k;bool vis[55];sg[0] = 0; sg[1] = 0; sg[2] = 1;for (i = 3; i <= 50; ++i){memset(vis, false, sizeof(vis));for (j = 0; j < i / 2; ++j){int temp = sg[j] ^ sg[i - j - 2];vis[temp] = 1;}j = 0;while (vis[j]) j++;sg[i] = j;}}int main(){initsg();int n;while (scanf("%d", &n) != EOF){int a, ans = 0;for (int i = 0 ;i < n; ++i){scanf("%d", &a);ans ^= sg[a];}if (ans) printf("Yes\n");else printf("No\n");}return 0;}
- ZOJ 2083 SG函数
- ZOJ 3084 SG函数
- ZOJ 2083 SG博弈
- ZOJ 2725 SG函数 DP
- ZOJ 1827 SG函数 或 dp
- zoj 3666 Alice and Bob , SG函数
- ZOJ 3666 Alice and Bob(博弈 sg 函数入门)
- zoj 3529 博弈SG
- ZOJ 2507 Anti-SG
- ZOJ 3113 Anti-SG
- sg函数
- SG函数
- SG函数
- SG函数
- SG函数
- SG函数
- SG函数
- SG函数
- 关于sscanf函数的一些一些
- 如何调用父类的构造函数?
- cocos2d-x基础.
- Linux上配置Nginx+PHP5(FastCGI)
- 《Recommender Systems Handbook》读书笔记
- ZOJ 2083 SG函数
- windowsService
- 老虎机的制作
- 单打基本战术
- 究竟wifi是怎么定位我的?迷局与真相,阴谋与阳谋
- CYPEESS USB3.0程序解读之---GPIO
- Makefile经典教程(掌握这些足够)
- C#性能优化实践
- android中 MediaStore提取缩略图和原始图像