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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
$('#InsertProduct').click(function () { var index = layer.open({ type: 2, title: ["化妆品检测下单申请单", "text-align:center;font-size: 24px;"], area: ['86%', '90%'], content: '/A_OrderDetectsModule/A01_ProductOrderTest/CosmTestApplication', btn: ['导入', '重置', '保存', '生成委托单', '二次建单', '提交', '关闭'], maxmin: true, scrollbar: true, success: function (layero) { var btnLayer = layero.find('.layui-layer-btn'); btnLayer.css({ 'text-align': 'center', 'background-color': '#33ABA0', 'color': '#fff', 'border': 'none' }); var btnLayer = layero.find('.layui-layer-btn0'); btnLayer.css({ 'text-align': 'center', 'background-color': '#fff', 'color': '#202124', 'border': 'none' }); $('.layui-layer-btn').find('a').eq(0).attr('id', 'ImportBtn'); // 导入 $('.layui-layer-btn').find('a').eq(1).attr('id', 'ResetBtn'); // 重置 $('.layui-layer-btn').find('a').eq(2).attr('id', 'PreserveBtn'); // 保存 $('.layui-layer-btn').find('a').eq(2).attr('lay-submit', ''); $('.layui-layer-btn').find('a').eq(2).attr('lay-filter', 'component-form-element'); $('.layui-layer-btn').find('a').eq(3).attr('id', 'GenerateDelegatOrderBtn'); // 生成委托单 $('.layui-layer-btn').find('a').eq(4).attr('id', 'SecondaryOrderCreationBtn'); // 二次建单 $('.layui-layer-btn').find('a').eq(5).attr('id', 'SubmitBtn'); // 提交 $('.layui-layer-btn').find('a').eq(6).attr('id', 'CloseBtn'); // 关闭 }, restore: function () { //监听还原窗口restore方法 $('.layui-layer').css({ 'top': '45px', 'left': '130px' }); } }); layer.full(index); });为什么点击保存按钮模态框会闪退
最新发布
07-23
点击保存按钮后,模态框闪退可能是因为表单提交的处理逻辑有问题。在你的代码中,你给保存按钮添加了 `lay-submit` 和 `lay-filter` 属性,这表明你想使用 Layui 的表单提交功能。 然而,根据你提供的代码,我没有看到你定义 `component-form-element` 这个 `lay-filter` 的地方。这个问题可能导致了表单提交失败,从而引发模态框闪退。 为了解决这个问题,你可以按照以下步骤进行调试: 1. 确保在 HTML 中的表单元素上添加了 `layui-form` 类名和 `lay-filter` 属性,例如 `<div class="layui-form" lay-filter="modalForm">`。 2. 确保你已经正确加载了 Layui 的 form 模块,并且在 `layer.open()` 的 `success` 回调函数中初始化了表单验证。这一步骤在之前的回答中已经给出了示例代码。 3. 确保在表单中的保存按钮上添加了 `lay-submit` 和 `lay-filter` 属性,例如 `<button class="layui-btn" lay-submit lay-filter="component-form-element">保存</button>`。 4. 确保你已经定义了与保存按钮的 `lay-filter` 属性相对应的监听事件,例如: ```javascript layui.use(['form'], function() { var form = layui.form; // 监听保存按钮的点击事件 form.on('submit(component-form-element)', function(data) { // 表单验证通过,执行保存操作 saveForm(data.field); return false; // 阻止表单提交,如果不需要阻止提交可以移除此行 }); // 自定义保存表单函数 function saveForm(formData) { // 根据实际情况编写保存逻辑 console.log(formData); // 这里可以使用 formData 对象获取表单中的数据,然后进行保存操作 } }); ``` 请确保以上步骤都正确实现,并仔细检查是否还有其他可能导致模态框闪退的问题,比如 JS 报错、网络请求失败等。 如果问题仍然存在,请提供更多的代码和错误信息,以便我能够更好地帮助你解决问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值