Background
Lucy and Lily are twins. Today is their birthday. Mother buys a birthday cake for them.Now we put the cake onto a Descartes coordinate. Its center is at (0,0), and the cake's length of radius is 100.

There are 2N (N is a integer, 1<=N<=50) cherries on the cake. Mother wants to cut the cake into two halves with a knife (of course a beeline). The twins would like to be treated fairly, that means, the shape of
the two halves must be the same (that means the beeline must go through the center of the cake) , and each half must have N cherrie(s). Can you help her?
Note: the coordinate of a cherry (x , y) are two integers. You must give the line as form two integers A,B(stands for Ax+By=0), each number in the range [-500,500]. Cherries are not allowed lying on the beeline.
For each dataset there is at least one solution.
Input
The input file contains several scenarios. Each of them consists of 2 parts: The first part consists of a line with a number N, the second part consists of 2N lines, each line has two number, meaning (x,y) .There
is only one space between two border numbers. The input file is ended with N=0.
Output
For each scenario, print a line containing two numbers A and B. There should be a space between them. If there are many solutions, you can only print one of them.
Sample Input
2
-20 20
-30 20
-10 -50
10 -5
0
Sample Output
0 1
因为半径较小,A,B是整数,因此可以直接枚举暴力搜索
#include<iostream>
using namespace std;
struct Node
{
int x,y;
}node[120];
int num;
bool line(int a,int b)
{
int r=0,t=0;
for(int i=0;i<num;i++)
{
if(node[i].x*a+node[i].y*b<0) r++;
else if(node[i].x*a+node[i].y*b>0) t++;
else break;
}
if(t==r&&r==num/2) return true;
else return false;
}
int main()
{
int n;
while(cin>>n&&n)
{
int i,j;
num=0;
for(i=0;i<2*n;i++)
{
int x1,y1;
cin>>x1>>y1;
if(x1*x1+y1*y1<=10000)
{
node[num].x=x1;
node[num].y=y1;
num++;
}
}
//cout<<num<<endl;
int tag=0;
for(i=-100;i<=100;i++)
{
for(j=-100;j<=100;j++)
{
if(line(i,j))
{
cout<<i<<" "<<j<<endl;
tag=1;
break;
}
}
if(tag) break;
}
}
return 0;
}
分享到:
相关推荐
这个文件集合可能是一个小型的Web应用或者一个代码库,专门用于处理与“生日”相关的功能,考虑到“bir”这一标签可能代表了“birthday”的缩写。 首先,我们来看index.html。在Web开发中,这是网页的主入口文件,...
接着,课程介绍了不同类型的蛋糕,如fruit cake(水果蛋糕)、cartoon cake(卡通蛋糕)、chocolate cake(巧克力蛋糕)、tea cake(茶饼)和birthday cake(生日蛋糕)。这是对食物类别词汇的扩展,有助于孩子们...
这篇课件是针对新版PEP小学英语三年级上册的第六单元——"Happy Birthday!"的一堂"A Let's Talk"课程。这个单元旨在通过生日派对这一情境,帮助学生学习和运用与生日相关的英语词汇和基本句型,提升他们的口语交流...
:birthday_cake:弃权日 现在,您有机会与工作中的同事一起纪念重要的弃用日标记。毕竟,我们必须庆祝自己的成就。 正在安装 使用composer进行安装,或将每个文件从github ui复制粘贴到您的磁盘上。 $ composer ...
在这个"Happy-Birthday-Cake-Person"项目中,开发者显然利用了这一特性来实现一个庆祝生日的场景,可能涉及到一个会移动的蛋糕人或者与生日相关的互动元素。 Runtime NavMesh的主要功能是在游戏运行过程中生成、...
4. Are you going to buy a birthday cake? (作肯定回答) 回答Yes, I am. 是对学生一般将来时态的肯定回答能力的检验。 三、选词填空。 1. Forty and thirty is seventy. 这道题考查加法运算,以及使用"and"连接...
3. "Let’s eat the birthday cake." - 提议吃蛋糕时,表示赞同的答语是 "Great!" 选项C正确。 4. "This is for you!" - 收到礼物时,应该表示感谢,回答 "Thank you." 选项C正确。 三、对话排序 这是一段关于生日...
生日庆祝birthday
标题中的"birthday_v1.0.rar_Delphi birthday_v1_birthday_v1.0 delp_csv_delp"表明这是一个Delphi编程项目,主要用于处理CSV文件,版本为1.0。项目可能包含生日相关的功能,因为“birthday”这个词多次出现。"delp_...
happy_birthday
【标题】"Birthday.rar"是一个压缩包文件,通常用于存储多个相关文件或文件夹,便于传输和保存。在本例中,它可能包含了与“生日”主题相关的各种资源,如程序代码、图片、音乐或文档。 【描述】提到,这个压缩包...
3. **Let’s eat the birthday cake.** - 提议吃蛋糕,积极的回应是表示赞同,选项C "Great"。 4. **This is for you!** - 接收礼物时应表示感谢,因此选项C "Thank you" 是正确的。 三、对话排序 题目中给出的...
* Sincere birthday wishes(真诚的生日祝福语),如 "have a very happy birthday!" 3. 英文生日祝福语的语言特点 从文件的部分内容中,我们可以看出英文生日祝福语的语言特点: * 使用 poetical language(诗歌...
Birthday Calendar Get a birthday calendar for all your social networks right inside Google Calendar. Supports Facebook, LinkedIn, Xing, Skype, DavDroid and all other apps which sync contacts with ...
- 制作生日蛋糕:make a birthday cake - 收到生日礼物:get birthday presents - 送生日卡片:send a birthday card - 在中国式的生日派对上:have a Chinese-style birthday party - 用英语说这句话:say it ...
当我们尝试去解构一个名为“happy birthday.rar”的文件时,我们能够感受到一个充满爱意的创新想法正在诞生。这个特殊的压缩文件可能是包含了一个精心设计的网页程序,它利用了Web开发中的三大力量——JavaScript、...
标题 "Birthday-Property.zip_birthday" 提供了一个线索,这个压缩包包含的代码与“生日问题”(Birthday Paradox)有关。生日问题是一个经典的概率论问题,它探讨在一个房间里需要多少人,才能使其中至少有两个人...