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的倍数。具体的判断,初等数学知识。

 #include<cstdio>
struct Point
{
int x;
int y;
}p[];
int main()
{
int n,x,y;
while (scanf("%d", &n) != EOF)
{
for (int i = ; i <= n;i++) scanf("%d%d", &p[i].x, &p[i].y);
bool win = false;
if (n % )win = true;
else
{
for (int i = ; i <= n&&!win; i++)
for (int j = i+; j <= n&&!win; j++)
for (int k = j+; k <= n&&!win; k++)
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))
win = true;
}
if (win)printf("a is the lucky boy.\n");
else printf("b is the lucky boy.\n");
}
return ;
}

Lucky Boy的更多相关文章

  1. lucky 的 时光助理(2)

    lucky小姐说:昨天晚上他喝醉了,发消息说他想我了,说他后悔了. 我很惊讶. 我问lucky:你们很久都没有联系, 突然说... 你怎么想. 没错,'他'就是lucky的前男友. lucky看着我, ...

  2. lucky 的 时光助理

    2017年的lucky小姐,厌倦了现在的工作,她觉得这些的工作对于她而言不具备挑战性,她在迷茫春节过后该如何选择, 这里是距她走出校门整整一年的时光. lucky小姐从开发走向了实施,目的是想周游这个 ...

  3. ZOJ3944 People Counting ZOJ3939 The Lucky Week (模拟)

    ZOJ3944 People Counting ZOJ3939 The Lucky Week 1.PeopleConting 题意:照片上有很多个人,用矩阵里的字符表示.一个人如下: .O. /|\ ...

  4. Lucky and Good Months by Gregorian Calendar - POJ3393模拟

    Lucky and Good Months by Gregorian Calendar Time Limit: 1000MS Memory Limit: 65536K Description Have ...

  5. hdu 5676 ztr loves lucky numbers

    题目链接:hdu 5676 一开始看题还以为和数位dp相关的,后来才发现是搜索题,我手算了下,所有的super lucky number(也就是只含数字4, 7且4, 7的数量相等的数)加起来也不过几 ...

  6. Lucky 2048 - The secret of being lucky

    Lucky 2048 uses a normal distribution to create "lucky" start. Generally speaking, it prov ...

  7. 枚举 + 进制转换 --- hdu 4937 Lucky Number

    Lucky Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)To ...

  8. [py]简易pick lucky num程序

    程序功能: 1,用户输入数字,当用户输入指定数字时候,输出他输入的循环那次 2,第二次询问是否还要输 3,如果no 则 终止 4,如果yes则继续输入 判断输入是否大于首次输入的 如果大于则开始循环输 ...

  9. HDU 5213 Lucky 莫队+容斥

    Lucky Problem Description WLD is always very lucky.His secret is a lucky number K.k is a fixed odd n ...

  10. Gym 100637F F. The Pool for Lucky Ones

    F. The Pool for Lucky Ones Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...

随机推荐

  1. java初学者的Springmvc04笔记

    Springmvc04 Springmvc的全局异常处理 springmvc与spring的整合 myBatis 1.Springmvc的全局异常处理 作用:一次配置,对于controller层的所有 ...

  2. linux服务器外网内网(双网络)搭建

    一共有2台服务器,分别用a,b表示.a双网卡,即有外网也有内网.b只有内网环境.a,b的内网是通过交换机组建.至于外网怎么搭建我就不说了.关键说一说内网是怎么组建的. 如果你对linux不熟悉,对网卡 ...

  3. 【leetcode】1207. Unique Number of Occurrences

    题目如下: Given an array of integers arr, write a function that returns true if and only if the number o ...

  4. 1.端口被占用问题:Embedded servlet container failed to start. Port 8097 was already in use.

    1.端口被占用问题:Embedded servlet container failed to start. Port 8097 was already in use.netstat -anonetst ...

  5. 观察者模式------《Head First 设计模式》

    第二章---观察者模式 xzmxddx 学习方式:书籍<Head First 设计模式>,这本书通俗易懂,所有知识点全部取自本书. 面向对象设计原则 封装变化 多用组合,少用继承 针对接口 ...

  6. BZOJ 3398: [Usaco2009 Feb]Bullcow 牡牛和牝牛 水题~

    水~ #include <cstdio> #define N 100004 #define mod 5000011 #define setIO(s) freopen(s".in& ...

  7. 6.Python缩进规则(包含快捷键)

    和其它程序设计语言(如 Java.C 语言)采用大括号“{}”分隔代码块不同,Python 采用代码缩进和冒号( : )来区分代码块之间的层次. 在 Python 中,对于类定义.函数定义.流程控制语 ...

  8. 【Python】学习笔记三:序列

    sequence(序列) sequence(序列)是一组有序的元素的集合,序列可以有任何元素,也可以没有元素 元组与表的区别:一旦建立,tuple的各个元素不可再变更,而list的各个元素可以再变更 ...

  9. java生成二维码的几种方式

    1: 使用SwetakeQRCode在Java项目中生成二维码 http://swetake.com/qr/ 下载地址 或着http://sourceforge.jp/projects/qrcode/ ...

  10. SQL Server CDC最佳实践

    企业核心业务系统oltp的数据需要通过ETL同步到数据仓库,原始的ETL流程通过定制化从SQL Server中进行数据抽取,经过生产环境的监控,发现ETL过程的query会对生产系统造成额外负载.于是 ...