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 }
  • 相关阅读:
    Quartz.NET-2.3.3 各种 数据库配置 类别大全
    C#获取当前路径的七种方法 【转载】
    BCB 如何拦截TAB键消息
    用union 和 struct 位域操作
    表值函数
    C#中 委托和事件的关系
    关于C++ Builder Codegurad 问题的排查。
    存储过程中使用事务的“正规”写法
    C++ 中对vector<T*> 数组的查找和排序
    BCB 中 Application->CreateForm 和 New 的一个区别
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/7397252.html
Copyright © 2011-2022 走看看