poj 3975&&hdu 1850 (nim)

简介:
//赢得了上风
//从n几年移除堆叠一堆石头,有多少可取的石头堆
# include <stdio.h>
# include <string.h>
# include <algorithm>
using namespace std;
int main()
{
    int n,sum,i,j,a[1010],cot,vis[1010];
    while(~scanf("%d",&n),n)
    {
        sum=0;

        for(i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        memset(vis,0,sizeof(vis));
        cot=0;
        for(i=0;i<n;i++)
        {
            sum=0;
           vis[i]=1;
            for(j=0;j<n;j++)
            {
                if(!vis[j])
                  sum^=a[j];
            }
            vis[i]=0;
            if(a[i]>sum)//要异或到零的状态。由于要取出几个石头,全部a[i]要大于sum,同样的两个数异或为零
                cot++;
        }
        printf("%d\n",cot);
    }
    return 0;
}

版权声明:本文博客原创文章,博客,未经同意,不得转载。




本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/4658640.html,如需转载请自行联系原作者


相关文章
|
Java
hdu1209 Clock
hdu1209 Clock
41 0
POJ3678——Katu Puzzle(2-SAT)
POJ3678——Katu Puzzle(2-SAT)
146 0
POJ3678——Katu Puzzle(2-SAT)
[POJ3678] Katu Puzzle | 2-SAT 入门
Description Katu Puzzle is presented as a directed graph G ( V , E ) with each edge e ( a , b ) labeled by a boolean operator op (oneofAND,OR,XOR) and an integer c ( 0 ≤ c ≤ 1 ) . One Katu is solvable if one can find each vertex Vi a value X i ( 0 ≤ X i ≤ 1 )
POJ 2840 Big Clock
POJ 2840 Big Clock
113 0