zoukankan      html  css  js  c++  java
  • B. Godsend

    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.

     这道题就是比较综总和,然后分奇偶;这是我哇了两次竟然是Second拼写错了.(原谅我英语菜)

     1 #include <bits/stdc++.h>
     2 #define ll long long int
     3 using namespace std;
     4 int k[1000005];
     5 int main(){
     6   int n;
     7   ll sum=0;
     8   int j=0,o=0;
     9   scanf("%d",&n);
    10   for(int i=0;i<n;i++){
    11     scanf("%d",&k[i]);
    12     if(k[i]%2==0)
    13       o++;
    14     else
    15       j++;
    16     sum+=k[i];
    17   }
    18   if(sum%2==0&&j==0)
    19     printf("Second
    ");
    20   else
    21     printf("First
    ");
    22   return 0;
    23 }
  • 相关阅读:
    算法分析之最小子段求和
    算法分析之最大子段求和(二)
    算法分析之爬楼梯问题
    .net编码规则
    tensorflow mnist
    The tensorflow simplest calculate
    python opencv
    english
    opencv 图片识别
    随机概率
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/7397252.html
Copyright © 2011-2022 走看看