alice and boooooooob_geometric games

I wrote a few blogs and I feel...the code is relatively simple..Actually, I am not very familiar with the data structure now. I see a geometric game problem, I feel...a bit interesting.

The main idea of ​​the title is Alice and boooob (anyway, I said his name is boooob, he is booob), God arranged it, the biggest. They are playing a game, there is a triangle, you give the point, then alice finds a point (she's very smart), then bob draws a line through this point, and he takes the largest area , how to draw this line to obtain the largest area?


Idea: First of all, Alice is very smart.. She will definitely choose a point that is beneficial to herself, so that no matter how bob draws the line, the difference between herself and Alice will be the smallest, so how will she choose a point? Think about it, there are only three special points inside a triangle, the center of gravity, the outer center, and the inner center, the outer center is impossible, think about an obtuse triangle. The heart is impossible. For example, if the two sides of a triangle are very long and the third side is very short, then boob must have a lot of points... if he is not an sb.

In this way, assuming that it is the center of gravity, how does Bob divide it? If he is sb, then it is divided according to the center line, which is the worst case (1, 1); then is there an optimal case? Suppose he divides the center of gravity parallel to the base of the triangle, then the ratio of the upper and lower areas will be 4:5. Is there a better way to divide it? The answer is no, it can be proved that:

According to t(AE:AC) and s=2sinA*|AD|*|AE|, the function of s with respect to t can be listed, and the derivative of t=2/3 is the only extreme point, the minimum point. (that is, when DE is parallel to BC), this is the optimal solution of bob.

So can alice choose other points to get more benefits? The answer is no, assuming a point, and then Bob takes the optimal solution, it is obvious that Bob will get more points.

The code is relatively simple:

#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
int x[3],y[3];
scanf("%d %d %d %d %d %d",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2]);double s=abs((x[1]-x[0])*(y[2]-y[0])-(x[2]-x[0])*(y[1]-y[0]))/2.0;s=s*5/9;printf("%.1lf\n",s);return 0; } 







Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325933976&siteId=291194637