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 }
  • 相关阅读:
    Notification(一)系统通知的监听移除
    控制器的生命周期
    Foundation Framework
    View的生命周期方法:loadView、viewDidLoad、viewDidUnload的关系
    第一篇markdown博文
    0622.获取json文件的数据
    0622.发送邮件基本操作
    0622.设置tableView的背景图片(平铺的方式)
    0621.用WebView展示html数据
    iOS的Quartz2D篇——基本图形的绘制
  • 原文地址:https://www.cnblogs.com/hsd-/p/6017512.html
Copyright © 2011-2022 走看看