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

      

  • 相关阅读:
    Python环境的导入导出
    Jenkins+Ant+Jmeter搭建轻量级接口自动化(转载)
    VMware桥接模式连接局域网和互联网
    安装KVM
    [Beyond Compare] 排除/忽略 .svn 文件夹
    Git 如何放弃所有本地修改
    Python2 和 Python3 共存于 Centos7
    kubernetes 之部署metrics-server
    在CentOS 7.6 以 kubeadm 安装 Kubernetes 1.15 最佳实践
    华为云 Kubernetes 管理员实训 五 课后作业
  • 原文地址:https://www.cnblogs.com/a972290869/p/4222369.html
Copyright © 2011-2022 走看看