Lucky Boy
Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)
Recently, Lur have a good luck. He is also the cleverest boy in his school as he create the most popular computer game – Lucky Boy. The game is played by two players, a a and b b, in 2 2d planar .In the game Lucky Boy, there are n n different points on plane, each time one can remove one or multiple co-line points from the plane. The one who can firstly remove more than two points from the plane wins. The one who removes the last point on the plane can also win the game. You may assume that two players are both clever enough that they can always make the best choice. The winner is called Lucky Boy.
Given the n points, can you tell me who will be the Lucky Boy ? Note that player a will always the first one to remove points from the plane.
Input
The first line of each case is an integer
n(0<n≤103)
n(0<n≤103), following
n
n lines each contains two integers
x
x and
y(0≤x,y≤108)
y(0≤x,y≤108), describing the coordinates of each point. Ended byEOF
.
Output
Output a is the lucky boy.
in a single line if a win the game, otherwise you should output b is the lucky boy.
in a single line.
Sample Input | Sample Output |
---|---|
3 0 0 1 1 2 2 3 0 0 1 1 2 3 | a is the lucky boy. b is the lucky |
Sample input and output
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
double a[1003][2];
int n;
int main()
{
while(scanf("%d",&n) != EOF)
{
int sum = 0;
for(int i = 0; i < n; i++)
{
scanf("%lf%lf",&a[i][0],&a[i][1]);
}
int flag = 0;
for(int i = 0; i < n; i++)
{
for(int j = i+1; j < n; j++)
{
double a1 = a[j][1]-a[i][1],a2;
double b1 = a[i][0]-a[j][0],b2;
double c1 = a[j][0]*a[i][1] - a[j][1]*a[i][0],c2;
for(int k = j+1; k < n; k++)
{
a2 = a[k][1]-a[i][1];
b2 = a[i][0]-a[k][0];
c2 = a[k][0]*a[i][1] - a[k][1]*a[i][0];
if((a1*b2 == a2*b1) && a1*c2 == a2*c1)
{
flag = 1;
break;
}
}
if(flag)break;
}
if(flag)break;
}
if(flag || n%3 || n <= 2)printf("a is the lucky boy.\n");
else printf("b is the lucky boy.\n");
}
return 0;
}