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 }
  • 相关阅读:
    3. 无重复字符的最长子串
    24. 两两交换链表中的节点
    2. 两数相加
    23. 合并K个排序链表
    synergy配置 Ubuntu作Server, Win 7作client
    ros与下位机通信常用的c++ boost串口应用
    tar
    发布里程计传感器信息
    ROS TF——learning tf
    在linux终端下打开pdf文件
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/7397252.html
Copyright © 2011-2022 走看看