zoukankan      html  css  js  c++  java
  • Codeforces841B

    B. Godsend

    time limit per test:2 seconds
    memory limit per test:256 megabytes
    input:standard input
    output:standard output

    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 ≤ 106) — length of the array.

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

    Output

    Output answer in single line. "First", if first player wins, and "Second" otherwise (without quotes).

    Examples

    input

    4
    1 3 2 3

    output

    First

    input

    2
    2 2

    output

    Second

    Note

    In first sample first player remove whole array in one move and win.

    In second sample first player can't make a move and lose.

     水了一天。。。

     1 //2017-08-22
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <iostream>
     5 #include <algorithm>
     6 
     7 using namespace std;
     8 
     9 const int N = 1000010;
    10 int arr[N];
    11 
    12 int main()
    13 {
    14     int n;
    15     std::ios::sync_with_stdio(false);
    16     while(cin>>n){
    17         long long sum = 0;
    18         int odd = 0, even = 0;
    19         for(int i = 0; i < n; i++){
    20               cin>>arr[i];
    21             sum += arr[i];
    22             if(arr[i]&1)odd++;
    23             else even++;
    24         }
    25         if(sum & 1)cout<<"First"<<endl;
    26         else{
    27             if(odd == 0)cout<<"Second"<<endl;
    28             else cout<<"First"<<endl;
    29         }
    30     }
    31 
    32     return 0;
    33 }
  • 相关阅读:
    第十五周作业
    十三周作业
    第十三周上机作业
    第十二周作业
    第十二周作业
    第十一周作业
    第十一周上机作业
    第十次上机作业
    第九周上机作业
    安卓第一周
  • 原文地址:https://www.cnblogs.com/Penn000/p/7413627.html
Copyright © 2011-2022 走看看