zoukankan      html  css  js  c++  java
  • Codeforces841B

    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.

     水了一天。。。

     1 //2017-08-22
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <iostream>
     5 #include <algorithm>
     6 
     7 using namespace std;
     8 
     9 const int N = 1000010;
    10 int arr[N];
    11 
    12 int main()
    13 {
    14     int n;
    15     std::ios::sync_with_stdio(false);
    16     while(cin>>n){
    17         long long sum = 0;
    18         int odd = 0, even = 0;
    19         for(int i = 0; i < n; i++){
    20               cin>>arr[i];
    21             sum += arr[i];
    22             if(arr[i]&1)odd++;
    23             else even++;
    24         }
    25         if(sum & 1)cout<<"First"<<endl;
    26         else{
    27             if(odd == 0)cout<<"Second"<<endl;
    28             else cout<<"First"<<endl;
    29         }
    30     }
    31 
    32     return 0;
    33 }
  • 相关阅读:
    Vue开源项目库汇总【壮灬哥出品,必为精品】
    nginx配置
    找出判断数据是否有相同的值
    CSS设置文字不能被选中
    js怎么删数组固定的值
    IO流中File文件最常用和直接的用法
    JComboBox实现当前所选项功能和JFrame窗口释放资源的dispose()方法
    java中经常使用的Swing组件总结
    JTextArea利用JScrollpane增加文本域滚轮(滚动条)
    JFrame关闭程序就退出的设置
  • 原文地址:https://www.cnblogs.com/Penn000/p/7413627.html
Copyright © 2011-2022 走看看