HDU
来源:互联网 发布:邻里中国网php面试题 编辑:程序博客网 时间:2024/06/08 13:38
SG函数应用
#include<iostream>#include<algorithm>#include<cstdio>#include<cstdlib>#include<cstring>#include<string>#include<cmath>#include<set>#include<queue>#include<stack>#include<map>using namespace std;typedef long long ll;const int maxn = 1e4 + 7, INF = 0x7f7f7f7f, mod = 1e9 + 7;int sg[maxn], temp = 1;set<int> st;int k, a[maxn], vis[maxn] = {0};void init() {//cout << " === " << endl; sg[0] = 0; for(int i = 1; i <= 10000; ++i) { temp++; for(int j = 0; a[j] <= i && j < k; ++j) { vis[sg[i-a[j]]] = temp; } for(int j = 0; j <= i; ++j) if(vis[j] != temp) { sg[i] = j; break; } }}int main() { int T, n, x; while(~scanf("%d", &k) && k) { for(int i = 0; i < k; ++i) scanf("%d", &a[i]); sort(a, a+k); init(); scanf("%d", &T); while(T--) { scanf("%d", &n); int ans = 0; while(n--) { scanf("%d", &x); ans ^= sg[x]; } if(ans == 0) printf("L"); else printf("W"); } puts(""); } return 0;}
阅读全文
1 0
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- hdu
- HDU
- 老鼠试药问题
- 前端学习第六弹:制作一个简易导航
- [JZOJ2393]【ZJOI2011】营救皮卡丘
- shiro cookie
- tensorflow 学习笔记之 变量的一些操作
- HDU
- 第10周项目实践 线索二叉树的建立及遍历
- Hbase命令
- SpringMVC(1)----@RequestParam和@PathVariable用法小结
- jqwidgets 国际化- 中文 jqxGrid 中文语言包 gridlocalization
- Android知识点(一)
- Spring cloud系列七 为@Feign中集成的Ribbon进行个性化配置
- Codeforces Round #440 B. Maximum of Maximums of Minimums-【思维】
- 整合webview的一些资料