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 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
题意:
	一个以原点为中心的圆,告诉你圆上的一个点,求与另外的两个点组成的三角形的周长最长的两点作标。
 
思路:
	设P(x,y),一个方程是pow(x,2)+pow(y,2)=pow(r,2);另一个方程是根据向量知识,向量的夹角公式得到方程。
因为圆心角夹角为120度,已知一个向量(即一个点作标),所以COS(2PI/3)=a*b/|a|*|b|;(a,b为向量);
已知角和a向量,就可求b向量b(x,y).由方程组可求得(x,y);最后得到的是一元二次方程组,可得到两个解,即为两个点的作标。

代码:

#include <stdio.h>
#include <math.h>
#define PI 3.1415926

int main()
{
	double x,y,x1,y1,x2,y2,cosx,a,b,c,r,delta;
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%lf%lf",&x,&y);
		r=sqrt(x*x+y*y);
		a=r*r;
		b=r*r*y;
		c=r*r*r*r/4-x*x*r*r;
		delta=b*b-4*a*c;
		y1=(-1*b-sqrt(delta))/(2*a);
		y2=(-1*b+sqrt(delta))/(2*a);
		if(x==0)
		{
			x1=-sqrt(r*r-y1*y1);
			x2=sqrt(r*r-y2*y2);
		}
		else
		{
			x1=(-1*r*r/2-y*y1)/x;
			x2=(-1*r*r/2-y*y2)/x;
		}
		printf("%.3lf %.3lf %.3lf %.3lf/n",x1,y1,x2,y2);
	}
	return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-08-05 07:05:59

hdu 1700 Points on Cycle(几何)(中等)的相关文章

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

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

暑假集训(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 2348 Turn the corner(三分&amp;&amp;几何)(中等)

Turn the corner Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2229    Accepted Submission(s): 856 Problem Description Mr. West bought a new car! So he is travelling around the city. One day h

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

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

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