本文主要是介绍A. Find Color,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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:
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.
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.
Find the required color.
All the points between which and the origin of coordinates the distance is integral-value are painted black.
-2 1
white
2 1
black
4 3
black
/* ***********************************************
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的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!