pku 2234 matches game 博弈

来源:互联网 发布:php商城开源 编辑:程序博客网 时间:2024/06/02 05:57

pku 2234 matches game 博弈

算法:看了张一飞对博弈题的介绍,根据他的结论A.可以说是最简单的博弈题。为了纪念一下第一道博弈题:

 

#include <stdio.h>

#include <string.h>

#define M 25

 

int main()

{

       int i, n;

       long result;

       long number[M];

       while (scanf("%d", &n) != EOF)

       {

              memset(number, 0, sizeof(number));

              for (i = 0; i < n; i++)

              {

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

              }

              if (n == 0)

              {

                     printf("No/n");

                     continue;

              }

              else if (n == 1)

              {

                     printf("Yes/n");

                     continue;

              }

              else

              {

                     result = number[0];

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

                     {

                            result ^= number[i];

                     }

                     if (result)

                     {

                            printf("Yes/n");

                     }

                     else

                     {

                            printf("No/n");

                     }

              }

       }

       return 0;

}

原创粉丝点击