-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA_Find_Color.cpp
50 lines (44 loc) · 958 Bytes
/
A_Find_Color.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// update code
#include <bits/stdc++.h>
using namespace std;
string dc(int x, int y) {
double d = sqrt(x * x + y * y);
if (d == floor(d)) {
return "black";
}
int radius = ceil(d);
if (x * y > 0) {
return (radius % 2 == 0) ? "white" : "black";
} else {
return (radius % 2 != 0) ? "white" : "black";
}
}
int main() {
int x, y;
cin >> x >> y;
cout << dc(x, y) << endl;
return 0;
}
/*#include <bits/stdc++.h>
using namespace std;
int main()
{
int x, y;
cin >> x >> y;
bool isBlack = false;
if ((x > 0 && y >= 0) || (x < 0 && y <= 0))
{
if (x % 2 != 0 && y%2 ==0)
isBlack = true;
}
else if ((x < 0 && y >= 0) || (x > 0 && y <= 0))
{
if (x % 2 == 0 )
isBlack = true;
}
if (isBlack)
cout << "white" << endl;
else
cout << "black" << endl;
}
*/