HDU1700 Points on Cycle (最大内接三角形)

题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=1700

题意:

一个圆心为原点的圆,告诉你圆上一点,求圆上另外两点的坐标使圆的面积最大

分析:

三角形的面积由底边和高两个因素决定,不管底边所在弦有多少,

但其高只有经过圆心的为最大,

故毫无质疑必须是等腰三角形。

设等腰三角形ABC,高AH,圆心O,AO=BO=R,OH=AH-AO,设高为x,

BH=√[R^2-(x-R)^2]=√(2Rx-x^2),

∴S=x√(2Rx-x^2),

dS=√(2Rx-x^2)+(1/2)*(2Rx-x^2)^(-1/2)*(2R-2x)*x=(2Rx-x^2+Rx-x^2)/√(2Rx-x^2)=0,

2x^2-3Rx=0,

x=3R/2,根据实际问题,该驻点有极大值,

即当x=3R/2时有最大面积,而高AH=3R/2,正是正三角形,

∴当圆内接正三角形时具有最大面积。

已知A(a,b), 设B(x,y),,

cos(2pi/3)=向量OA*向量OB/|OA|*|OB|;

( ax+b*y ) =  -1/2 * R*R; --------1)

a*a + b*b = R*R;  -----------2)

x*x + y*y = R*R   -----------3)

一二三式联立可以解出两个点的坐标,注意x=0的时候

代码如下:

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        double x1,y1,r;
        scanf("%lf%lf",&x1,&y1);
        r = x1*x1+y1*y1;
        double a = 1;
        double b = y1;
        double c = r/4-x1*x1;
        double delta = b*b-4*a*c;
        double ansy1 = (-b-sqrt(delta))/2/a;
        double ansy2 = (-b+sqrt(delta))/2/a;
        double ansx1,ansx2;
        if(fabs(x1)<=1e-7){
            ansx1 = -sqrt(r-ansy1*ansy1);
            ansx2 =  sqrt(r-ansy2*ansy2);
        }
        else{
            ansx1 = (-r/2-y1*ansy1)/x1;
            ansx2 = (-r/2-y1*ansy2)/x1;
        }
        printf("%.3lf %.3lf %.3lf %.3lf\n",ansx1,ansy1,ansx2,ansy2);
    }
    return 0;
}
时间: 2024-08-24 13:26:32

HDU1700 Points on Cycle (最大内接三角形)的相关文章

暑假集训(2)第八弹 ----- Points on Cycle(hdu1700)

Points on Cycle Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description There is a cycle with its center on the origin. Now give you a point on the cycle, you are to find out the other two points on it, to maximize th

hdu 1700 Points on Cycle(几何)(中等)

Points on Cycle Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1992    Accepted Submission(s): 721 Problem Description There is a cycle with its center on the origin. Now give you a point on t

hdu 1700 Points on Cycle 水几何

已知圆心(0,0)圆周上的一点,求圆周上另外两点使得三点构成等边三角形. 懒得推公式,直接用模板2圆(r1=dist,r2=sqrt(3)*dist)相交水过 #include<cstdio> #include<iostream> #include<cmath> #include<algorithm> #include<iterator> using namespace std; #define eps 1e-6 typedef long lon

hdu 1700 Points on Cycle(坐标旋转)

http://acm.hdu.edu.cn/showproblem.php?pid=1700 Points on Cycle Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1567    Accepted Submission(s): 570 Problem Description There is a cycle with its c

Points on Cycle

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description There is a cycle with its center on the origin. Now give you a point on the cycle, you are to find out the other two points on it, to maximize the sum of the dis

L - Points on Cycle

Description There is a cycle with its center on the origin. Now give you a point on the cycle, you are to find out the other two points on it, to maximize the sum of the distance between each other you may assume that the radius of the cycle will not

ACM——Points on Cycle

Description There is a cycle with its center on the origin. Now give you a point on the cycle, you are to find out the other two points on it, to maximize the sum of the distance between each other you may assume that the radius of the cycle will not

2016HUAS_ACM暑假集训2L - Points on Cycle(圆上的点)

一个简单的几何题,自己在纸上列出方程解出结果的表达式,再用程序表达出来就行了. 大致题意:一个圆心在原点的圆,半径未知,现在给你圆上的一点,让你在这个圆上找到另外两点,使得这三点构成的三角形的周长最长. 样例输入:(第一行为一个整数N,表示后面有N组案例,每个案例给出一组圆上点的坐标) 2 1.500        2.000 563.585    1.251 样例输出:(其他两个点的坐标) 0.982 -2.299 -2.482 0.299 -280.709  -488.704  -282.8

HDU 1700 Points on Cycle (几何 向量旋转)

http://acm.hdu.edu.cn/showproblem.php?pid=1700 题目大意: 二维平面,一个圆的圆心在原点上.给定圆上的一点A,求另外两点B,C,B.C在圆上,并且三角形ABC的周长是最长的. 解题思路: 我记得小学的时候给出个一个定理,在园里面正多边形的的周长是最长的,这个定理我不会证明. 所以这里是三角形,当三角形为正三角形的时候,周长是最长的. 因为圆心在原点,所以我就向量(x,y)绕原点逆时针旋转120度和顺时针旋转120度.给定的点A可以看成(x,y)向量.