Created
November 5, 2012 10:59
-
-
Save Abreto/4016631 to your computer and use it in GitHub Desktop.
UVaOJ 10167 - Birthday Cake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* UVaOJ 10167 - Birthday Cake */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
int is_available(int a, int b); | |
int N = 0; | |
int x[100]={0}, y[100]={0}; | |
int main(void) | |
{ | |
srand((unsigned int)time(NULL)); | |
while( scanf("%d", &N) != EOF ) | |
{ | |
int i = 0; | |
int A = 0, B = 0; | |
if( !N ) break; | |
for(i = 0;i < (N<<1);i++) | |
scanf("%d %d", x+i, y+i); | |
while(1) | |
{ | |
A = -500 + rand()%1001; | |
B = -500 + rand()%1001; | |
if( !(is_available(A, B)) ) | |
break; | |
} | |
printf("%d %d\n", A, B); | |
} | |
return 0; | |
} | |
int is_available(int a, int b) | |
{ | |
int i = 0; | |
int diff = 0; | |
for(i = 0;i < (N<<1);i++) | |
{ | |
int t = a*x[i] + b*y[i]; | |
if( 0 == t ) | |
return -1; | |
else | |
diff += (t>0)?(1):(-1); | |
} | |
return diff; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment