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 }
  • 相关阅读:
    Python服务Dokcer化并k8s部署实例
    Docker Machine
    Docker使用Portainer搭建可视化界面
    三小时攻克 Kubernetes!
    Docker使用pipework配置本地网络
    使用kubeadm安装kubernetes1.12.2版本脚本【h】
    rsync详解之exclude排除文件(转)
    linux生成指定大小的文件(转)
    chown将指定文件的拥有者改为指定的用户或组(转)
    Linux系统分析命令总结
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/7397252.html
Copyright © 2011-2022 走看看