40A_Find Color

A. Find Color
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Not so long ago as a result of combat operations the main Berland place of interest — the magic clock — was damaged. The cannon's balls made several holes in the clock, that's why the residents are concerned about the repair. The magic clock can be represented as an infinite Cartesian plane, where the origin corresponds to the clock center. The clock was painted two colors as is shown in the picture:

The picture shows only the central part of the clock. This coloring naturally extends to infinity.

The balls can be taken to be points on the plane. Your task is to find the color of the area, damaged by the given ball.

All the points located on the border of one of the areas have to be considered painted black.

Input

The first and single line contains two integers x and y — the coordinates of the hole made in the clock by the ball. Each of the numbers xand y has an absolute value that does not exceed 1000.

Output

Find the required color.

All the points between which and the origin of coordinates the distance is integral-value are painted black.

Examples
input
-2 1
output
white
input
2 1
output
black
input
4 3
output

black



题意:随意给一点坐标,找出该坐标区域的颜色。

若恰好在边界,即为黑色。

思路:求该点到原点的距离,与半径比较。

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
    int x,y;
    while(~scanf("%d%d",&x,&y))
    {
        double z=sqrt(x*x*1.0+y*y*1.0);
        int k=(int) z;
        if(z==k)
        {
            printf("black\n");
            continue;
        }
        if(x>0&&y>0||x<0&&y<0)
        {
            if(k&1)
                printf("white\n");
            else
                printf("black\n");
        }
        else
        {
            if(k&1)
                printf("black\n");
            else
                printf("white\n");
        }
    }
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值