hdu 1700 Points on Cycle(几何)(中等)
来源:互联网 发布:新版mac mini 发布时间 编辑:程序博客网 时间:2024/05/21 08:39
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.
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.
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
21.500 2.000563.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.1415926int 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;}
0 0
- hdu 1700 Points on Cycle(几何)(中等)
- hdu 1700 Points on Cycle 水几何
- HDU 1700 Points on Cycle
- HDU-1700 Points on Cycle
- 【计算几何】 HDOJ 1700 Points on Cycle
- HDU1700:Points on Cycle
- HDU 1700 || Points on Cycle (向量旋转,圆上等边三角形的周长最长
- hdu1700 Points on Cycle (数学)
- HDU1700 Points on Cycle(感觉很重要)
- hdu 1700 Points on circle(三角函数应用)
- HDU1700 Points on Cycle (最大内接三角形)
- hdu 2348 Turn the corner(三分&&几何)(中等)
- ural 1489. Points on a Parallelepiped 计算几何
- 186.Max Points on a Line-最多有多少个点在一条直线上(中等题)
- hdu 1540 难度:中等
- ZOJ 1081 Points Within (几何)
- 【几何】-POJ-3805-Separate Points
- codeforces251A. Points on Line
- 1026. Table Tennis (30)
- 利用MyBatis生成器自动生成实体类、DAO接口和Mapping映射文件
- Java方法中的参数传递方式
- linux oracle修改最大连接数
- HDU 3729 I'm Telling the Truth
- hdu 1700 Points on Cycle(几何)(中等)
- 链表的创造(我的困难主要在这)
- Class 类的用法
- 15/8/3/网络连接,UDP,DOM,SAX,JSON
- 逆序的BSF输出
- QDBus与gdbus的数据传递详解
- HDU 1021 Fibonacci Again
- Delphi7第八天---小型图书管理系统
- 项目分析(2)