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;
    
    }
    

      

  • 相关阅读:
    解题报告:luogu P3853 [TJOI2007]路标设置
    解题报告:luogu P2678 跳石头
    SG函数
    解题报告:CF622F
    解题报告:luogu P1144 最短路计数
    树剖小结(简述)
    LCA之tarjan离线
    %你赛2020.2
    一个小证明(题解 P5425 Part1)
    科创版简介
  • 原文地址:https://www.cnblogs.com/a972290869/p/4222369.html
Copyright © 2011-2022 走看看