• A. The King's Race


                                                                                                                                                                               A. The King's Race
     

    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
     4
    2 3
    output
    White
    input
    5
    3 5
    output
    Black
    input
    2
    2 2
    output
    Black

    题目大意:先输入棋盘的大小n,代表有一n*n的棋盘,在输入一个坐标x,y,白国王从(1,1)先出发,黑国王从(n,n)出发,问谁能先到达指定的位置。

    解决方法:其实可以在棋盘的左上和右下对角线连起来,不难发现当所要到达的点在对角线以上时总是黑国王获胜,当其在对角线上或在对角线以下时总是白国王获胜,判断一下位置即可。

     1 #include<bits/stdc++.h>
     2 
     3 using namespace std;
     4 typedef long  long ll;
     5 ll n,x,y;
     6 
     7 int main()
     8 {
     9     std::ios::sync_with_stdio(false),cin.tie(0);
    10     //freopen("in.txt","r",stdin);
    11     cin>>n>>x>>y;
    12     if(x+y>n+1)cout<<"Black"<<endl;
    13     else cout<<"White"<<endl;
    14     return 0;
    15 }
  • 相关阅读:
    HDU-2222 Keywords Search(AC自动机)
    HDU-2647 Reward(拓扑排序)
    HDU-2896 病毒侵袭(AC自动机)
    UESTC-1057 秋实大哥与花(线段树+成段加减+区间求和)
    CSU-1120 病毒(最长递增公共子序列)
    记忆化搜索
    区间动态规划 矩阵连乘 Medium
    34枚金币时间管理法
    摄影基础1
    学习法则 讲
  • 原文地址:https://www.cnblogs.com/kuroko-ghh/p/9960431.html
Copyright © 2020-2023  润新知