• 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 }
  • 相关阅读:
    nyoj 19擅长排列的小明 (DFS)
    POJ 1321棋盘问题
    线段树与树状数组草稿
    组合博弈入门知识汇总
    组合博弈入门(题目练习及代码解析)
    pandas 连接数据库直接查表建立dataframe。loc,sort_values数据清洗操作
    Django 项目内利用ORM直接运行脚本读库
    Pandas库中的DataFrame
    利用pandas对numpy数组进行简单的科学计算
    进程池 爬去梨视频 视频资源
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/7397252.html
Copyright © 2020-2023  润新知