zoukankan      html  css  js  c++  java
  • Lyft Level 5 Challenge 2018

    http://codeforces.com/contest/1075/problem/A

    On a chessboard with a width of nn and a height of nn, rows are numbered from bottom to top from 11 to nn, columns are numbered from left to right from 11 to nn. Therefore, for each cell of the chessboard, you can assign the coordinates (r,c)(r,c), where rr is the number of the row, and cc is the number of the column.

    The white king has been sitting in a cell with (1,1)(1,1) coordinates for a thousand years, while the black king has been sitting in a cell with (n,n)(n,n) coordinates. They would have sat like that further, but suddenly a beautiful coin fell on the cell with coordinates (x,y)(x,y)...

    Each of the monarchs wanted to get it, so they decided to arrange a race according to slightly changed chess rules:

    As in chess, the white king makes the first move, the black king makes the second one, the white king makes the third one, and so on. However, in this problem, kings can stand in adjacent cells or even in the same cell at the same time.

    The player who reaches the coin first will win, that is to say, the player who reaches the cell with the coordinates (x,y)(x,y) first will win.

    Let's recall that the king is such a chess piece that can move one cell in all directions, that is, if the king is in the (a,b)(a,b) cell, then in one move he can move from (a,b)(a,b) to the cells (a+1,b)(a+1,b), (a1,b)(a−1,b), (a,b+1)(a,b+1), (a,b1)(a,b−1), (a+1,b1)(a+1,b−1), (a+1,b+1)(a+1,b+1), (a1,b1)(a−1,b−1), or (a1,b+1)(a−1,b+1). Going outside of the field is prohibited.

    Determine the color of the king, who will reach the cell with the coordinates (x,y)(x,y) first, if the white king moves first.

    Input

    The first line contains a single integer nn (2n10182≤n≤1018) — the length of the side of the chess field.

    The second line contains two integers xx and yy (1x,yn1≤x,y≤n) — coordinates of the cell, where the coin fell.

    Output

    In a single line print the answer "White" (without quotes), if the white king will win, or "Black" (without quotes), if the black king will win.

    You can print each letter in any case (upper or lower).

    Examples
    input
    Copy
    4
    2 3
    output
    Copy
    White
    input
    Copy
    5
    3 5
    output
    Copy
    Black
    input
    Copy
    2
    2 2
    output
    Copy
    Black

    代码:

    #include <bits/stdc++.h>
    using namespace std;
    
    long long N;
    long long x, y;
    
    int main() {
        cin >> N;
        cin >> x >> y;
        long long step1 = 0, step2 = 0;
        step1 = min(abs(x - 1), abs(y - 1)) + abs(x - y);
        step2 = min(abs(x - N), abs(y - N)) + abs(x - y);
        if(step1 <= step2)
            printf("White
    ");
        else
            printf("Black
    ");
        return 0;
    }
    

      

    AC 的第一道 Div.2 的题目 可能是本年度唯一一道吧 【微笑脸】

  • 相关阅读:
    Win7 vs2017 WDK 1803 1809 驱动开发 出错 KMDF
    http 请求 post get 长度限制
    IO模式和IO多路复用(阻塞IO、非阻塞IO、同步IO、异步IO等概念)
    select/poll 和 epoll 比较
    centos查看端口被哪个应用端口占用命令
    mysql索引知识简单记录
    Spring钩子方法和钩子接口的使用详解
    mysql使用自增Id为什么存储比较快
    分布式Id教程
    如何配置JVM系统属性及获取方式System.getProperty("pname")
  • 原文地址:https://www.cnblogs.com/zlrrrr/p/9928121.html
Copyright © 2011-2022 走看看