zoukankan      html  css  js  c++  java
  • 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 2001 计算两点的距离
    hdu 2001 计算两点的距离
    hdu 2000 ASCII码排序(c语言)
    hdu 2000 ASCII码排序(c语言)
    1.网页学习-开始学习第一步:
    .net 父窗口线程交给子窗口
    多线程传递多个参数
    not Exists的使用方法
    xml.dom.minidom介绍
    .net之线程控件之间访问
  • 原文地址:https://www.cnblogs.com/kuroko-ghh/p/9960431.html
Copyright © 2011-2022 走看看