• HDU 2509 nim博弈


    Be the Winner

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 3326    Accepted Submission(s): 1853


    Problem 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 "@" or "@ @"(two piles). two people get apples one after another and the one who takes the last is
    the loser. Fra wants to know in which situations he can win by playing strategies (that is, no matter what action the rival takes, fra will win).
     
    Input
    You will be given several cases. Each test case begins with a single number n (1 <= n <= 100), followed by a line with n numbers, the number of apples in each pile. There is a blank line between cases.
     
    Output
    If a winning strategies can be found, print a single line with "Yes", otherwise print "No".
     
    Sample Input
    2 2 2 1 3
     
    Sample Output
    No Yes
     
    Source
    题意:同hdu1907  链接
    题解:
     1 /******************************
     2 code by drizzle
     3 blog: www.cnblogs.com/hsd-/
     4 ^ ^    ^ ^
     5  O      O
     6 ******************************/
     7 #include<bits/stdc++.h>
     8 #include<map>
     9 #include<set>
    10 #include<cmath>
    11 #include<queue>
    12 #include<bitset>
    13 #include<math.h>
    14 #include<vector>
    15 #include<string>
    16 #include<stdio.h>
    17 #include<cstring>
    18 #include<iostream>
    19 #include<algorithm>
    20 #pragma comment(linker, "/STACK:102400000,102400000")
    21 using namespace std;
    22 #define  A first
    23 #define B second
    24 const int mod=1000000007;
    25 const int MOD1=1000000007;
    26 const int MOD2=1000000009;
    27 const double EPS=0.00000001;
    28 typedef __int64 ll;
    29 const ll MOD=1000000007;
    30 const int INF=1000000010;
    31 const ll MAX=1ll<<55;
    32 const double eps=1e-14;
    33 const double inf=~0u>>1;
    34 const double pi=acos(-1.0);
    35 typedef double db;
    36 typedef unsigned int uint;
    37 typedef unsigned long long ull;
    38 int n;
    39 int ans,cou;
    40 int main()
    41 {
    42     while(scanf("%d",&n)!=EOF)
    43     {
    44         ans=cou=0;
    45         int exm;
    46         for(int j=1; j<=n; j++)
    47         {
    48             scanf("%d",&exm);
    49             ans^=exm;
    50             if(exm>1)
    51                 cou++;
    52         }
    53         if((ans==0&&cou>=2)||(cou==0&&ans%2!=0))
    54             printf("No
    ");
    55         else
    56             printf("Yes
    ");
    57     }
    58     return 0;
    59 }
  • 相关阅读:
    【BZOJ1854】游戏[SCOI2009](神奇贪心+并查集)
    P4177 [CEOI2008]order(网络流)最大权闭合子图
    P2472 [SCOI2007]蜥蜴(网络流)
    P2877 [USACO07JAN]牛校Cow School(01分数规划+决策单调性分治)
    bzoj3437 小P的牧场(斜率优化dp)
    P3628 [APIO2010]特别行动队(斜率优化dp)
    P3648 [APIO2014]序列分割(斜率优化dp)
    P4027 [NOI2007]货币兑换(斜率优化dp+cdq分治)
    P2365 任务安排 / [FJOI2019]batch(斜率优化dp)
    P3195 [HNOI2008]玩具装箱TOY(斜率优化dp)
  • 原文地址:https://www.cnblogs.com/hsd-/p/6017512.html
Copyright © 2020-2023  润新知