hdu 2509 Be the Winner

详解:hdu 1907 John - lihaogegehuting的专栏 - 博客频道 - CSDN.NET

两道题几乎一样

代码如下:

#include<stdio.h>
int main()
{
  int T,a[100],i,sum,ok;
  while(~scanf("%d",&T))
  {

            sum=0;
            ok=0;

        for(i=1;i<=T;i++)
          {
             scanf("%d",&a[i]);
             if(a[i]>1) ok=1;
             sum=sum^a[i];
          }
          if(ok==0)
           {
                if(T%2==0)
                  printf("Yes\n");
                  else
                   printf("No\n");
           }
           else
            if(sum==0)
              printf("No\n");
              else
               printf("Yes\n");

     }               

  return 0;
}

hdu 2509 Be the Winner

时间: 2024-10-12 06:32:00

hdu 2509 Be the Winner的相关文章

HDU 2509 Be the Winner(取火柴博弈2)

传送门 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int main() { int n; while(~scanf("%d",&n)) { int a,res=0; int c=0,g=0; for(int i=0;i<n;i++) { scanf("%d",&a); if(a>=2) c++;

HDU 2509 Nim博弈

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2509 题意:有N堆,谁最后拿谁输. 关键:判断孤单堆. 1 #include<cstdio> 2 #define ll long long 3 using namespace std; 4 5 int main() 6 { 7 int n; 8 while( ~scanf("%d",&n)){ 9 int temp,ans=0,flag=0; 10 for(int i=

HDU 2509——anti-nim

题目: Description Let's consider m apples divided into n groups. Each group contains no more than 100 apples, arranged in a line. You can take any number of consecutive apples at one time. For example "@@@" can be turned into "@@" or &qu

hdu 2509 博弈 *

多堆的情况要处理好孤单堆 1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<cstring> 5 #include<cmath> 6 #include<queue> 7 #include<map> 8 using namespace std; 9 #define MOD 1000000007 10 const int INF=0

Hdoj 2509 Be the Winner

Diciption Let's consider m apples divided into n groups. Each group contains no more than 100 apples, arranged in a line. You can take any number of consecutive apples at one time. For example "@@@" can be turned into "@@" or "@&q

博弈题目小结

HDU 2174 kiki's game 题意:有一个N*M的棋盘,起点在右上角,两个人每轮可把棋子向左.向下或者向左下移动一格,直到不能移动棋子者输. NP图解决: 概念: 必败点(P点):前一个选手将取胜的位置称为必败点. 必胜点(N点):下一个选手将取胜的位置成为必胜点. 性质: 步骤: NP图: AC code: 1 #include <bits/stdc++.h> 2 #define inc(i, j, k) for(int i = j; i <= k; i++) 3 #def

HDU 5754 Life Winner Bo 组合博弈

Life Winner Bo Problem Description Bo is a "Life Winner".He likes playing chessboard games with his girlfriend G. The size of the chessboard is N×M.The top left corner is numbered(1,1) and the lower right corner is numberd (N,M). For each game,B

【博弈论】HDU 5754 Life Winner Bo

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5754 题目大意: 4种棋子,象棋中的 1王,2车,3马,4后,选其一,B和G轮流走,不能往左上走,一开始棋子在(1,1),谁先走到(n,m)谁赢,无法走动算平局D. (n,m<=1000,case<=1000) 题目思路: [博弈论] 这题博弈论.怎样都输为必败,只能走到必败的为必胜. 王:(王可以横竖斜走一格)如果n个m均为奇数先手必败,否则必胜. 从3x3格子看,当n和m均为奇数时先手必败,

HDU 5754 Life Winner Bo 2016多校第三场1003

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5754 题意:给你一个n*m大小的棋盘,分别以国际象棋的国王.战车.骑士和皇后的走法从(1,1)走到(n,m),而且只能向右或者向下走,问谁有必胜的策略或者是两者平局. 题解:无论是哪一种移动,都可以注意到,如果从起点到某一个点有必胜的策略,那么再以必胜点作为起点可以走到下一个必胜点,也就是以小见大. 一.对于王的走法,可以注意到3*3大小的棋盘,从(1,1)到(3,3)后手是有必胜的策略的,对于N和