HDU 1850 Being a Good Boy in Spring Festival

/*

Nim模型

*/



#include<stdio.h>

#include<string.h>

#include<stdlib.h>

const int MAXM = 105;

int m, ni[MAXM];



int main()

{

    int i, cnt, res;

    while(scanf("%d", &m), m)

    {

        res = cnt = 0;

        for(i = 1; i <= m; i ++)

        {

            scanf("%d", &ni[i]);

            res ^= ni[i];

        }

        if(res == 0) //异或为0,先手必败,所以输出0

        {

            puts("0");

        }

        else

        {

            for(i = 1; i <= m; i ++)

            {

                if((res ^ ni[i]) < ni[i])

                    cnt ++;

            }

            printf("%d\n", cnt);

        }

    }

    return 0;

}

 

你可能感兴趣的:(spring)