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

      

  • 相关阅读:
    android view生命周期
    ViewPager 滑动页(四)
    android 中如何获取camera当前状态
    Android LayoutInflater原理分析,带你一步步深入了解View(一)
    仿Twitter登陆移动背景效果
    Android应用性能优化之使用SQLiteStatement优化SQLite操作
    GreenDao官方文档翻译(下)
    高级IO
    linux信号
    LINUX进程
  • 原文地址:https://www.cnblogs.com/a972290869/p/4222369.html
Copyright © 2011-2022 走看看