zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    母版页中对控件ID的处理
    使用Gridview绑定数据库中的图片
    导出Excel表格时,如何把数据库表中的编号转换成配置文件中的"汉字"
    ORA01502: 索引'P_ABCD.PK_WEB_BASE'或这类索引的分区处于不可用状态
    Oracle 把触发器说透
    规模估算失准 软件开发成空中楼阁
    在web开发中的三个层次使用事务
    oninput,onpropertychange,onchange的用法和区别
    Oracle 把游标说透
    在datatable中,在指定位置插入列
  • 原文地址:https://www.cnblogs.com/hsd-/p/6017512.html
Copyright © 2011-2022 走看看