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 distance between each other 
you may assume that the radius of the cycle will not exceed 1000.

Input

There are T test cases, in each case there are 2 decimal number representing the coordinate of the given point.

Output

For each testcase you are supposed to output the coordinates of both of the unknow points by 3 decimal places of precision 
Alway output the lower one first(with a smaller Y-coordinate value), if they have the same Y value output the one with a smaller X.

NOTE

when output, if the absolute difference between the coordinate values X1 and X2 is smaller than 0.0005, we assume they are equal.

Sample Input

2
1.500 2.000
563.585 1.251

Sample Output

0.982 -2.299 -2.482 0.299
-280.709 -488.704 -282.876 487.453

//题目大意是一个圆内有一点(半径未知),要求过这个点做圆内最大周长的三角形

这道题其实不难,关键是你能不能找到公式... 就是旋转向量法(算法竞赛入门经典训练指南256页),没有书就用普通方法也行:

一个圆的内接三角形周长最长的是正三角形。设给出的为点A(x,y),圆的半径为R,连接AO,反向延长AO与圆交于点O‘,以O‘为圆心,R为半径画圆,两个圆的交点坐标就是所求的答案。

这个方法就看我同学的博客吧!点击查看

下面是我的:

#include <iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>

using namespace std;
const  double PI=acos(-1.0);
struct Point
{
    double x;
    double y;
    Point(double x = 0, double y = 0): x(x), y(y){}
};
typedef Point Vector;
Vector Rotate(Vector A, double rad)//向量旋转公式
{
    return Vector(A.x * cos(rad) - A.y * sin(rad), A.y * cos(rad) + A.x * sin(rad));
}

int main()
{
    Point point[3];
    int n;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%lf %lf",&point[0].x,&point[0].y);
        point[1]=Rotate(point[0],PI*2/3);//逆时针旋转120度
        point[2]=Rotate(point[0],-PI*2/3);//顺时针旋转120度
        int maxPoint=(point[1].y<point[2].y || point[1].y==point[2].y && point[1].x<point[2].x)?1:2;//排序
        if(maxPoint==1)
            printf("%.3lf %.3lf %.3lf %.3lf\n",point[1].x,point[1].y,point[2].x,point[2].y);
        if(maxPoint==2)
            printf("%.3lf %.3lf %.3lf %.3lf\n",point[2].x,point[2].y,point[1].x,point[1].y);
    }
    return 0;
}

时间: 2024-08-02 23:07:48

Points on Cycle的相关文章

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

暑假集训(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(坐标旋转)

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

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

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=√(2

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)向量.