Skip to content

Instantly share code, notes, and snippets.

@nomarlo
Created January 8, 2017 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nomarlo/52f2e1715b6b0d94afed495020b235fa to your computer and use it in GitHub Desktop.
Save nomarlo/52f2e1715b6b0d94afed495020b235fa to your computer and use it in GitHub Desktop.
/**
La idea es encontrar el angulo punto que nos dan, usan atan(y/x), comparandolo con nuestros angulos inicial y final
y finalmente que la distancia del punto al centro sea menor o igual al radio
**/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cstdio>
#define PI 3.14159265
using namespace std;
typedef vector<double> vd;
typedef pair<double, double> point;
int t, p, x, y;
point center;
double m, b;
double r = 50.0;
int res , c = 1;
bool isInside (point Ve1){
return pow(Ve1.first - center.first, 2) + pow(Ve1.second - center.second, 2) <= pow (r, 2);
}
int main(){
double a0, a1, a2;
a0 = PI/2.0;
center = make_pair(50.0, 50.0);
scanf("%d", &t);
while(t--){
scanf("%d %d %d", &p, &x, &y);
res = 0;
if(p <= 25 ) a1 = (PI / 2) - ( 2 *PI * ( p / 100.0) );
else if (p <= 50 ) a1 = (PI * 2) - ( (2* PI * ( p / 100.0)) - (PI / 2) );
else if (p <= 75 ) a1 = (PI * (3/2) ) - ( (2* PI * ( p / 100.0)) - (PI / 2) );
else a1 = (PI) - ( (2* PI * ( p / 100.0)) - (PI / 2) );
a2 = atan(y/x) ;
if(isInside (make_pair(x,y)) ){
if( p <= 25){
if( a2 >= a1 && a2 <= a0) res = 1;
}
else {
if ( a2 >= a1 || a2 <= a0) res = 1;
}
}
printf("Case #%d: %s\n", c, res ? "black" : "white");
c++;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment