Lucky Boy

Lucky Boy

 

Problem Description

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 and b, in 2d planar .In the game Lucky Boy, there are 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), following n lines each contains two integers x and y(0<=x, y<=108), describing the coordinates of each point. Ended by EOF.

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

3
0 0
1 1
2 2
3
0 0
1 1
2 3

Sample Output

a is the lucky boy.
b is the lucky boy.

描述:

题目大意,就是说呢,有两个孩子一起玩游戏,分别是 A 和 B一起玩。 这个游戏呢,很简单就是说,现在有 n 个石头吧,然后每次可以拿一条直线上面的所有石头,要么一次拿3个及以上的人可以赢,要么就是最后一次拿石头的人可以赢。然后A先拿。 所以呢,对于第一种赢的方式,只要有3个石头同一条线,A是肯定会赢的,如果没有三个石头同一条线的话,这就是一个博弈了。如果剩下1个石头或者两个石头,那么那个人是比赢的,因此想要自己赢,就得让对手拿的时候是3块石头可以了。所以对于A而言,如果现在是3块石头,那么自己就会输,因为每次A,B都是选最优的,只要A拿的时候是3的倍数,那么A就会输。比如说现在有6个石头,A可以拿1个或者两个,那么B像赢,只要让剩下的是3个就可以了,那么A拿一个,B就拿两个, A拿两个,B就拿1个,对于9个石头,无论A拿一个还是两个,B只要让剩下的是6个就好了。所以,如果石头是3的倍数,A必输。因此先判断有没有3个石头是在一条线上的,再判断是不是3的倍数。具体的判断,初等数学知识。

 1 #include<cstdio>
 2 struct Point
 3 {
 4     int x;
 5     int y;
 6 }p[1010];
 7 int main()
 8 {
 9     int n,x,y;
10     while (scanf("%d", &n) != EOF)
11     {
12         for (int i = 1; i <= n;i++) scanf("%d%d", &p[i].x, &p[i].y);
13         bool win = false;
14         if (n % 3)win = true;
15         else
16         {
17             for (int i = 1; i <= n&&!win; i++)
18                 for (int j = i+1; j <= n&&!win; j++)
19                     for (int k = j+1; k <= n&&!win; k++)
20                         if ((p[i].x - p[j].x)*(p[i].y - p[k].y) == (p[i].x - p[k].x)*(p[i].y - p[j].y))
21                             win = true;
22         }
23         if (win)printf("a is the lucky boy.\n");
24         else printf("b is the lucky boy.\n");
25     }
26     return 0;
27 }
View Code

 

posted @ 2019-07-19 09:15  龚政  阅读(306)  评论(0编辑  收藏  举报