Lucky Boy
Lucky Boy
Problem Description
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
following n lines each contains two integers x and y(0<=x, y<=108),
describing the coordinates of each point. Ended by EOF.
Output
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的更多相关文章
- lucky 的 时光助理(2)
lucky小姐说:昨天晚上他喝醉了,发消息说他想我了,说他后悔了. 我很惊讶. 我问lucky:你们很久都没有联系, 突然说... 你怎么想. 没错,'他'就是lucky的前男友. lucky看着我, ...
- lucky 的 时光助理
2017年的lucky小姐,厌倦了现在的工作,她觉得这些的工作对于她而言不具备挑战性,她在迷茫春节过后该如何选择, 这里是距她走出校门整整一年的时光. lucky小姐从开发走向了实施,目的是想周游这个 ...
- ZOJ3944 People Counting ZOJ3939 The Lucky Week (模拟)
ZOJ3944 People Counting ZOJ3939 The Lucky Week 1.PeopleConting 题意:照片上有很多个人,用矩阵里的字符表示.一个人如下: .O. /|\ ...
- Lucky and Good Months by Gregorian Calendar - POJ3393模拟
Lucky and Good Months by Gregorian Calendar Time Limit: 1000MS Memory Limit: 65536K Description Have ...
- hdu 5676 ztr loves lucky numbers
题目链接:hdu 5676 一开始看题还以为和数位dp相关的,后来才发现是搜索题,我手算了下,所有的super lucky number(也就是只含数字4, 7且4, 7的数量相等的数)加起来也不过几 ...
- Lucky 2048 - The secret of being lucky
Lucky 2048 uses a normal distribution to create "lucky" start. Generally speaking, it prov ...
- 枚举 + 进制转换 --- hdu 4937 Lucky Number
Lucky Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)To ...
- [py]简易pick lucky num程序
程序功能: 1,用户输入数字,当用户输入指定数字时候,输出他输入的循环那次 2,第二次询问是否还要输 3,如果no 则 终止 4,如果yes则继续输入 判断输入是否大于首次输入的 如果大于则开始循环输 ...
- HDU 5213 Lucky 莫队+容斥
Lucky Problem Description WLD is always very lucky.His secret is a lucky number K.k is a fixed odd n ...
- 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 ...
随机推荐
- 【SaltStack官方版】—— MANAGING THE JOB CACHE
MANAGING THE JOB CACHE The Salt Master maintains a job cache of all job executions which can be quer ...
- springCloud——Dalston.SR5升级到Greenwich.SR2
老项目: SpringBoot 版本 :1.5.13.RELEASE SpringCloud 版本:Dalston.SR5 项目升级: SpringBoot 版本 :2.1.6.RELEASE Spr ...
- 阿里云移动研发平台 EMAS 助力银行业打造测试中台,提升发版效能
随着移动互联网的发展,手机银行凭借低成本.操作简单.不受时间空间约束等优势,正逐步替代传统的网银交易方式.越来越多的银行开始了“业务移动化”转型之路,“手机APP”已经成为企业价值传递和关系维护的关键 ...
- 使用bitmap实现对一千万个无重复的正整数(范围1~1亿)快速排序
1 Bytes(字节) == 8 bit 1 KBytes == 1024 Bytes 思路: 1)申请长度为1亿的保存二进制位的数组 a, 2)通过位运算,将整数做为索引,将数组a对应的索引位置为1 ...
- 状态管理-vuex
1.使用vuex // 使用vuex // 第一步:装包npm i vuex -S // 第二步: import Vuex from 'vuex' Vue.use(Vuex) // 第三步: cons ...
- 【CF1252L】Road Construction(基环树,最大流)
题意:给定一张n点n边无重边自环的无向图,刚开始每条边都没有被选择,每条边上有一个颜色集合,必须从中选择一种 有K个工人,每个工人有颜色a[i],需要把工人分配到与其颜色相同的边上 问是否能有一种使得 ...
- bootstrap的editTable实现方法
首先下载基于bootstrap的源码到本地.引用相关文件. <link href="/Content/bootstrap/css/bootstrap.min.css" rel ...
- Windows2008 r2“Web服务器HTTP头信息泄露”漏洞修复
一.漏洞名称 漏洞名称 漏洞摘要 修复建议 Web服务器HTTP头信息泄露 远程Web服务器通过HTTP头公开信息. 修改Web服务器的HTTP头以不公开有关底层Web服务器的详细信息. 说明:在ii ...
- QBXT Day 5图论相关
图论是NOIP的一个非常重要的考点,换句话说,没有图论,NOIP的考纲就得少一大半(虽然很NOIP没有考纲) 图论这玩意吧,和数论一样是非常变态的东西,知识点又多又杂,但是好在一个事,他比较直观比较好 ...
- docker常用软件安装及使用
linux安装docker: sudo wget -qO- https://get.docker.com | sh 启动docker: service docker start 搜索镜像: docke ...