codeforces 40A. Find Color
来源:互联网 发布:最难的网络游戏知乎 编辑:程序博客网 时间:2024/06/08 01:57
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.
水题代码就不注释了
AC代码:
# include <stdio.h># include <math.h> using namespace std;typedef long long int ll;int judge(int x, int y){if(x<0&&y<0){return 3;}else if(x<0&y>0){return 2;}else if(x>0&&y>0){return 1;}else if(x>0&&y<0){return 4;}else{return 0;}}int main(){int i, j, k, x, y;scanf("%d%d", &x, &y);int ans=judge(x, y);int d1=floor(sqrt((double)x*x+(double)y*y));int d2=ceil(sqrt((double)x*x+(double)y*y));if(ans==0){printf("black");}else if(ans==1){if(d1==d2){printf("black");}else{if(d2%2==0){printf("white");}else{printf("black");}}}else if(ans==2){if(d1==d2){printf("black");}else{if(d2%2==0){printf("black");}else{printf("white");}}}else if(ans==3){if(d1==d2){printf("black");}else{if(d2%2==0){printf("white");}else{printf("black");}}}else{if(d1==d2){printf("black");}else{if(d2%2==0){printf("black");}else{printf("white");}}}return 0;}
- codeforces 40A. Find Color
- A. Find Color
- 【浮点取整】#39 A.Find Color
- codeforces 804A Find Amir
- codeforces 804A——Find Amir
- codeforces 900A. Find Extra One
- 【Codeforces Round #411 (Div. 1)】Codeforces 804A Find Amir
- codeforces C. Color Stripe
- 小白题解 Codeforces 804A Find Amir
- Codeforces-809C Find a car(分治)
- [数位DP] Codeforces 809C. Find a car
- [数位DP] Codeforces #809C. Find a car
- Color a Tree
- Color a Tree
- Pku2054 Color a Tree
- poj2054 Color a Tree
- POJ2054.Color a Tree
- hdu_1055 Color a Tree
- Language Models
- csh shell编程入门
- 使用visualvm远程监控JVM LINUX tomcat服务器与客户端配置方法
- 对于唯一索引使用唯一条件搜索, InnoDB 只锁定找到的index record,不是它之前的区间
- 第6课:<body>标签
- codeforces 40A. Find Color
- HDU-1081-To The Max(二维最大子段和)
- boost 库 安装
- git 保存用户名和密码
- 第7课:p、hx、em、strong标签
- 数据结构--栈-编写一个算法输出n个布尔量的所有可能的组合
- 滴滴顺风车体验
- 《剑指offer》两个栈建立队列
- optionMenu如何弹出