zoukankan      html  css  js  c++  java
  • CSU 2018年12月月赛 H(2220): Godsend

    Description

    Leha somehow found an array consisting of n integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero length with an odd sum of numbers and remove it from the array, after that the remaining parts are glued together into one array and the game continues. The second player can choose a subsegment of non-zero length with an even sum and remove it. Loses the one who can not make a move. Who will win if both play optimally?

    Input

    First line of input data contains single integer n (1 ≤ n ≤ 1000000) — length of the array.

    Next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 1000000000).

    Output

    Output answer in single line.

    "First", if first player wins, and "Second" otherwise (without quotes).

    Sample Input

    4
    1 3 2 3

    Sample Output

    First

    题意:给你n个数,第一个人能删去一个连续的子串当且只当这个连续子串所有数之和为奇数,同理第二个人删的是和为偶数的子串,谁不能操作了谁输。考虑这个总串和为偶数的情况,因为为奇数的时候第一个人直接全删了。
       当总和为偶数的时候,如果所有的数都是偶数的话,第一个人就没有办法删了,所以第二个人赢,不然那第一个先删去一段子串,剩余的子串之和肯定为奇数。第二个人删去偶数,肯定不能全删了,剩余的肯定是奇数,
       那么第一个人必赢。综上,只有所有的数都是偶数的时候第二个人才赢,否则第一个人赢 。
    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <algorithm>
    #include <math.h>
    #include <set>
    using namespace std;
    const int maxn=230;
    int n,x,temp;
    string s;
    int main()
    {
        cin>>n;
        bool flag=false;
        while(n--)
        {
            scanf("%d",&x);
            if(x%2)
                flag=true;
        }
        if(flag==false)
            cout<<"Second"<<endl;
        else
            cout<<"First"<<endl;
        return 0;
    }
    
    /**********************************************************************
        Problem: 2220
        User: therang
        Language: C++
        Result: AC
        Time:256 ms
        Memory:2020 kb
    **********************************************************************/
  • 相关阅读:
    对于开发WEB方面项目需要的工具和技术了解
    SQLServer创建链接服务器
    Tomcat部署Web应用方法总结
    JDK/bin目录下的不同exe文件的用途
    js高级技巧自定义事件
    HTML5 web SQL
    js高级技巧拖放
    图片替换文字
    CSS内容生成(重要内容:css计数器)
    CSS 使元素垂直居中
  • 原文地址:https://www.cnblogs.com/jkzr/p/10163640.html
Copyright © 2011-2022 走看看