zoukankan      html  css  js  c++  java
  • 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;
    
    }
    

      

  • 相关阅读:
    02 日志系统: 一条SQL 更新语句是如何执行的
    MySql 实战45讲笔记 : 01
    爬取boss直聘全国招聘数据并做可视化
    爬取豆瓣电影-长津湖短评
    尝试破解压缩文件
    将webp格式的图像批量转化成jpg
    将JPG格式图片转换成PNG格式
    几个学习编程的游戏网站
    检测网址连接有效性
    监控设备电池电量并发送通知
  • 原文地址:https://www.cnblogs.com/a972290869/p/4222369.html
Copyright © 2011-2022 走看看