zoukankan      html  css  js  c++  java
  • Codeforce 513A

    Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.

    Input

    The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50.

    This problem doesn't have subproblems. You will get 3 points for the correct submission.

    Output

    Output "First" if the first player wins and "Second" otherwise.

    Examples
    input
    2 2 1 2
    output
    Second
    input
    2 1 1 1
    output
    First
    Note

    Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely.

     题解:每次都拿一个

     1 #include <iostream>
     2 #include <algorithm>
     3 #include <cstring>
     4 #include <cstdio>
     5 #include <vector>
     6 #include <cstdlib>
     7 #include <iomanip>
     8 #include <cmath>
     9 #include <ctime>
    10 #include <map>
    11 #include <set>
    12 using namespace std;
    13 #define lowbit(x) (x&(-x))
    14 #define max(x,y) (x>y?x:y)
    15 #define min(x,y) (x<y?x:y)
    16 #define MAX 100000000000000000
    17 #define MOD 1000000007
    18 #define pi acos(-1.0)
    19 #define ei exp(1)
    20 #define PI 3.141592653589793238462
    21 #define INF 0x3f3f3f3f3f
    22 #define mem(a) (memset(a,0,sizeof(a)))
    23 typedef long long ll;
    24 const int N=1005;
    25 const int mod=1e9+7;
    26 int main()
    27 {
    28 //    std::ios::sync_with_stdio(false);
    29     int n1,n2,k1,k2;
    30     cin>>n1>>n2>>k1>>k2;
    31     if(n1<=n2) cout<<"Second"<<endl;
    32     else if(n1>n2) cout<<"First"<<endl;
    33     return 0;
    34 }
  • 相关阅读:
    C++面试考点
    C++面试考点
    C++11 引用叠加规则和模板参数类型推导规则
    C++11 引用叠加规则和模板参数类型推导规则
    C++11 auto和decltype推导规则
    C++11 auto和decltype推导规则
    RVO和NRVO
    RVO和NRVO
    Strange Bank(找零问题)
    eli和字符串 (牛客假期训练)
  • 原文地址:https://www.cnblogs.com/wydxry/p/7262232.html
Copyright © 2011-2022 走看看