• cf 40A


    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 aninfinite 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.

    Sample test(s)
    input
    -2 1
    output
    white
    input
    2 1
    output
    black
    input
    4 3
    output
    black
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<string>
    #include<cmath>
    #include<algorithm>
    using namespace std;
    int x,y,l,r;
    int main()
    {
          scanf("%d%d",&x,&y);
          l=x*x+y*y;
          for(r=1;r*r<l;r++);
          printf((r*r==l||(r&1)^(x*y<0))?"black":"white");
          printf("
    ");
          return 0;
    
    }
    

      

  • 相关阅读:
    常用正则表达大全
    Vue 中Bus使用
    js 获取图片url的Blob值并预览
    npm install 插件 --save与 --save -dev的区别
    layui 事件监听触发
    微信小程序之回到顶部的两种方式
    HTML 命名规范!
    SpringMvc 集成支付宝沙盒测试
    Linux 的 tomcat 自起服务
    Linux 安装 tomcat8 详细步骤
  • 原文地址:https://www.cnblogs.com/a972290869/p/4222369.html
Copyright © 2020-2023  润新知