求到达必败态的方法数 ZOJ 3067 Nim
生活随笔
收集整理的這篇文章主要介紹了
求到达必败态的方法数 ZOJ 3067 Nim
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/*
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3067題意:求勝態到達必敗態的方法數Nim
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;int s[1005];int main(){
#ifndef ONLINE_JUDGEfreopen("in", "r", stdin);
#endifint n;while(scanf("%d", &n), n){int res = 0;for(int i=0; i<n; i++){scanf("%d", &s[i]);res ^= s[i];}if(res){int num = 0;for(int i=0; i<n; i++)if( (res^s[i]) <= s[i])// 要注意(),表示對s[i]的操作可以到達必敗態num++;printf("%d\n", num);}elseprintf("0\n");}return 0;
}
總結
以上是生活随笔為你收集整理的求到达必败态的方法数 ZOJ 3067 Nim的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: vue 直接访问静态图片_vue本地静态
- 下一篇: 1038 Recover the Sma