poj 2975 NIM
来源:互联网 发布:网络直播受众群体 编辑:程序博客网 时间:2024/05/17 05:02
题意:
在nim游戏中求先手能够取胜的方案数
分析:
我们知道一般求nim游戏是否能胜是把所有堆石头异或判断异或是否为0,如果为0必败,那么对于本题就是要求有几堆石头可以拿走一定的石头使得剩下的异或和为0
因为一个数异或自己为0 那么我们可以利用这点判断有几种方案
ACcode:
#include<iostream>#include<cstdio>#define maxn 1005using namespace std;int a[maxn];int main(){ int n,sg,ans; while(scanf("%d",&n),n){ sg=ans=0; for(int i=1;i<=n;++i){ scanf("%d",&a[i]); sg^=a[i]; } if(sg)for(int i=1;i<=n;++i)if((sg^a[i])<a[i])ans++; printf("%d\n",ans); } return 0;}
0 0
- POJ 2975 Nim <Nim 博弈>
- POJ-2975-Nim
- poj 2975 Nim 水
- POJ 2975 Nim
- POJ Nim (2975)
- poj 2975 Nim
- POJ 2975 Nim题解
- 【POJ 2975】 Nim 博弈论
- poj 2975 Nim
- poj 2975 Nim(博弈)
- poj 2975 NIM
- POJ 2975 Nim 题解
- 经典的NIM-poj-2975-Nim
- POJ 题目2975 Nim(nim)
- POJ 2975 Nim(nim博弈)
- POJ-2975-Nim(Nim博弈)
- POJ 2975 Nim (Nim的证明)
- [POJ](2975)Nim ---Nim博弈(博弈)
- 闪屏制作
- html5 常用 标签
- socket is closed异常的原因及其解决方法
- Java JDK Reflect
- RAID5/RAID0及LV制作
- poj 2975 NIM
- laravel 表单验证 (入门)
- Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset (multiset)
- 简单注解实现集群同步锁(spring+redis+注解)
- 自定义View实现圆形水波进度条
- QML 中的 XMLHttpRequest 对象
- HDU 4027 Can you answer these queries?(线段树)【The 36th ACM/ICPC Asia Regional 上海站网赛】
- PIRMER STL笔记(第三章中提到的vector)
- python中调用lua——(lupa)