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 的题目 可能是本年度唯一一道吧 【微笑脸】

  • 相关阅读:
    期望dp+高斯消元优化——uvalive4297好题
    期望dp+高斯消元+bfs——hdu4418
    倒车入库太难了?掌握技巧,其实它也可以很简单
    倒车影像辅助线怎么看_倒车影像怎么看图解
    教你手动挡驾驶技术如何提高驾车技巧
    【搜狐驾校】手动更安全 如何换档最合理
    专家告诉您:手动挡汽车驾驶技术
    Mybatis if test中字符串比较和Mybatis的like查询
    性能优化书籍
    微信就能查社保、开个税证明啦
  • 原文地址:https://www.cnblogs.com/zlrrrr/p/9928121.html
Copyright © 2011-2022 走看看