第四届吉林省大学生程序设计大赛个人解题报告 Problem B: The Farmer’s Heritage

本文讲述了第四届吉林省大学生程序设计大赛中的一个问题,即如何在给定三角形内找到一点,使得该点将三角形分成面积比为1/2:1/3:1/6的三个部分。通过计算几何的方法,利用三角形中位线的性质解决了问题,并给出了C++代码实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Problem B: The Farmer’s Heritage


A farmer who had worked hard all his life on his triangular farm was taken sick. He knew that he must soon die. He called his three sons about his bed to give them some advice. "My sons," said he, "keep all of the land which I leave you. Do not sell any of it, for there is a treasure in the soil. I shall not tell you where to hunt for it, but if you try hard to find it, and do not give up, you will surely succeed. As soon as the harvest is over, begin your search with plow, and spade, and rake. Turn every foot of earth, and then turn it again and again. The treasure is there." After the father died, the sons gathered in the harvest. As soon as the grain had been cared for, they planned to search for the hidden treasure. The farm was divided into three small triangles. Each son agreed to dig carefully his part. Every foot of soil was turned by the plow or by the spade. It was next harrowed and raked, but no treasure was found. That seemed very strange. "Father was an honest man and a wise man," said the youngest son. "He would never have told us to hunt for the treasure if it were not here. Do you not remember that he said, 'Turn the soil again and again'? He surely thought the treasure worth hunting for." "Our land is in such good condition now that we might as well sow winter wheat," said the oldest son. His brothers agreed to this and the wheat was sown. The next harvest was so great that it surprised them. No neighbor's field bore so many bushels of wheat to the acre. The sons were pleased with their success.   This story tells us that we must work hard to success. And do you know how these three sons divide the farm? Because of their ages, three sons acquired different are of this heritage. The eldest brother should get 1/2, the second should get 1/3, and the youngest son get 1/6.


Input
There are x and y coordinates of three triangle vertices in one line. These six
numbers are all real number. The edge against  the first vertex belongs to the eldest brother, the edge against the third vertex belongs to the youngest, and so the second. For each case, you should find a point inside the triangle that can divide the original triangle to three equal triangles.


Output
Output the x and y coordinates of the expected point in one line separate by a
space. Keep 3 digits after the decimal point.

 

Sample Input
0.0 0.0 0.0 6.0 6.0 0.0


Sample Output
1.000 2.000

 

      这道题算得上一道计算几何题,题目大概意思是:给你三个顶点的笛卡尔坐标,你的任务是在三角形内找到一点P,使得P与三个顶点的连线所分割的三角形面积比例为1/2 : 1/3 : 1/6,输出这个P点的坐标。

     这题很多人貌似一看就想到设P点坐标为(x0,y0),然后用海伦公式求出三个面的面积,然后列方程解出P点。但是这个思路不容易实现为算法,所以,需要找到一个更好的方法。

     可以看出,若做出三角形三边的中位线,三等分线,六等分线,将交于一点,该点即为所求的P点。具体实现的时候可以用向量的运算求P点,可以简化很多运算。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值