A. Find Color

2024-08-28 07:18
文章标签 find color

本文主要是介绍A. Find Color,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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 an infinite Cartesian plane, where the origin corresponds to the clock center. The clock was painted two colors as is shown in the picture:

A. Find Color - NGUNAUJ - NGUNAUJ

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
s
/* ***********************************************
Author :
Created Time :2015/6/15 2:56:21
File Name :7.cpp
************************************************ */

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 1<<30
#define maxn 10000+10
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;

bool cmp(int a,int b){
return a>b;
}
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int x,y;
while(cin>>x>>y){
if(x==0||y==0){
puts("black");continue;
}
if(x*y>0){
int d=x*x+y*y;
for(int i=0;i<=2000;i++){
if(d==i*i){
puts("black");break;
}
else if(d>i*i&&d<(i+1)*(i+1)){
if(i&1)puts("white");
else puts("black");
break;
}
}
}
else{
int d=x*x+y*y;
//cout<<sqrt(d)<<endl;
//cout<<d<<endl;
for(int i=0;i<=2000;i++){
if(d==i*i){
puts("black");break;
}
else
if(d>i*i&&d<(i+1)*(i+1)){
if(i&1)puts("black");
else puts("white");
break;
}
}
}
}
return 0;
}

这篇关于A. Find Color的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1114092

相关文章

三色标记(Tri-color marking)

维基百科部分 原文 https://en.wikipedia.org/wiki/Tracing_garbage_collection#TRI-COLOR Because of these performance problems, most modern tracing garbage collectors implement some variant of the tri-color ma

MongoDB学习—(6)MongoDB的find查询比较符

首先,先通过以下函数向BookList集合中插入10000条数据 function insertN(obj,n){var i=0;while(i<n){obj.insert({id:i,name:"bookNumber"+i,publishTime:i+2000})i++;}}var BookList=db.getCollection("BookList")调用函数,这样,BookList

【NodeJS】Error: Cannot find module 'ms'

转载自:http://blog.csdn.net/echo_ae/article/details/75097004 问题: Error: Cannot find module 'ms'at Function.Module._resolveFilename (module.js:469:15)at Function.Module._load (module.js:417:25)at Module

leetCode#448. Find All Numbers Disappeared in an Array

Description Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this

访问controller404:The origin server did not find a current representation for the target resource

ider build->rebuild project。Rebuild:对选定的目标(Project),进行强制性编译,不管目标是否是被修改过。由于 Rebuild 的目标只有 Project,所以 Rebuild 每次花的时间会比较长。 参考:资料

mybatis错误——java.io.IOException Could not find resource comxxxxxxMapper.xml

在学习Mybatis的时候,参考网上的教程进行简单demo的搭建,配置的没有问题,然后出现了下面的错误! Exception in thread "main" java.lang.RuntimeException: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause:

Linux 中的 find 命令介绍以及使用

文章目录 Linux 中的 `find` 命令详解及使用示例`find` 命令的基本语法常用的 `find` 命令选项按文件名搜索:`-name`按文件类型搜索:`-type`按文件大小搜索:`-size`按修改时间搜索:`-mtime`按权限搜索:`-perm`按所有者搜索:`-user` 和 `-group` `find` 命令的常见操作删除找到的文件:`-exec` 和 `rm`查找并

HDU 1556 Color the ball (树状数组-- 区间更新,单点求值)

OJ题目 :点这里~~ 与 单点更新,区间求值 稍有不同,需要理解注意。 AC_CODE int n;int num[100002];int lowbit(int x){return x&(-x);}int sum(int x){int ret = 0;while(x > 0){ret += num[x];x -= lowbit(x);}return ret;}void ad

mysql中find_in_set()函数

1.场景 假设有一个user用户表,表字段分别为:id(主键),name(姓名),age(年龄),hobby(爱好)。而一个人可能有好几个爱好,游泳啊篮球啊乒乓球啊等等。数据库里hobby字段存的是:游泳,篮球,乒乓球 而要想查所有喜欢游泳的人,就可以用find_in_set函数了 todo:贴图 2.使用 select *from user where find_in_set("游泳"

Failed to find style 'vpiCirclePageIndicatorStyle' in current theme

使用 ViewPagerIndicator 时 , 布局文件报的错 Missing styles. Is the correct theme chosen for this layout? Use the Theme combo box above the layout to choose a different layout, or fix the theme style refe