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
 

题意:以原点为圆心,给出圆上的一点,要求两位两点,是的这三个点的距离和最大,很容易想到这是一个等边三角形,而事实上,经过对题目给出样例的测试也证明了这确实是一个等边三角形

思路:几何水题

我们可以得到方程组

x^2+y^2 = r^2

(a-x)^2+(b-y^2)=3r^2

解方程组得到的两点即为三角形的另外两点

#include <stdio.h>
#include <math.h> int main()
{
int t;
double x,y,x2,y2,r;
double ax,ay,bx,by,k,m,l,A,B,C;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf",&x,&y);
r = x*x+y*y;
A = r;
B = y*r;
C = r*r/4-r*x*x;
ay = (-B-sqrt(B*B-4*A*C))/(2*A);
by = (-B+sqrt(B*B-4*A*C))/(2*A);
if(fabs(x-0)<1e-7)//防止除数出现0的情况
{
ax=-sqrt(r-ay*ay);
bx=sqrt(r-by*by);
}
else
{
ax=(-r/2-ay*y)/x;//由于ay必定小于by,所以ax也必定小于bx,所以无需进行大小判定
bx=(-r/2-by*y)/x;
}
printf("%.3lf %.3lf %.3lf %.3lf\n",ax,ay,bx,by);
}
return 0;
}

HDU1700:Points on Cycle的更多相关文章

  1. hdu1700 Points on Cycle

    地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=1700 题目: Points on Cycle Time Limit: 1000/1000 MS ...

  2. HDU-1700 Points on Cycle

    这题的俩种方法都是看别人的代码,方法可以学习学习,要多看看.. 几何题用到向量.. Points on Cycle Time Limit: 1000/1000 MS (Java/Others)     ...

  3. 暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)

                                                Points on Cycle Time Limit:1000MS     Memory Limit:32768 ...

  4. Points on Cycle (hdu1700,几何)

    Points on Cycle Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  5. hdu 1700 Points on Cycle(坐标旋转)

    http://acm.hdu.edu.cn/showproblem.php?pid=1700 Points on Cycle Time Limit: 1000/1000 MS (Java/Others ...

  6. L - Points on Cycle(旋转公式)

    L - Points on Cycle Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u ...

  7. hdu1700 Points on Cycle (数学)

    Problem Description There is a cycle with its center on the origin. Now give you a point on the cycl ...

  8. Points on cycle

    Description There is a cycle with its center on the origin. Now give you a point on the cycle, you a ...

  9. HDU 1700 Points on Cycle (坐标旋转)

    题目链接:HDU 1700 Problem Description There is a cycle with its center on the origin. Now give you a poi ...

随机推荐

  1. SGU 162.Pyramids

    时间限制:0.25s 空间限制:6M; 题意: 按照AB, AC, AD, BC, BD, CD.给出一个空间四面体的6条边长.求出它的体积. Solution: 欧拉四面体公式:           ...

  2. php 上传视频的代码

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  3. 一个CS出身的基本素养

    从前天10号提交Paper之后,连三个晚上之后突然正常起来竟然变成倒时差状态. 这周打算给自己一个空窗期,好好想想下两到三个月要做的事. 好吧,除了"一日一算法",当下两个月还有一 ...

  4. 解决Silverlight5_tools无法安装问题(试验已成功)

    当前位置: 银光首页 > Silverlight > Silverlight学习教程 > 命令:regedit 打开节点:HKEY_LOCAL_MACHINE\SOFTWARE\Mi ...

  5. python中对文件、文件夹的操作需要涉及到os模块和shutil模块。

    创建文件:1) os.mknod("test.txt") 创建空文件2) open("test.txt",w) 直接打开一个文件,如果文件不存在则创建文件 创建 ...

  6. RocksDB介绍:一个比LevelDB更彪悍的引擎

    关于LevelDB的资料网上还是比较丰富的,如果你尚未听说过LevelDB,那请稍微预习一下,因为RocksDB实际上是在LevelDB之上做的改进.本文主要侧重在架构上对RocksDB对LevelD ...

  7. JavaScript----Performance Tool and Process

    1. Syntax-------------JSLint, JSHint, 2. Combine------------YUI 3. Minify---------------JSMin

  8. jQuery Asynchronous

    http://www.ruanyifeng.com/blog/2011/08/a_detailed_explanation_of_jquery_deferred_object.html http:// ...

  9. Arctic Network

    poj2349:http://poj.org/problem?id=2349 题意:有卫星电台的城市之间可以任意联络.没有卫星电台的城市只能和距离小于等于D的城市联络.告诉你卫星电台的个数S,让你求最 ...

  10. 模拟I2C从机

    模拟I2C主机的比较多,但是从机相对主机而言要难很多,这个供大家借鉴. 这个从机程序支持主机对它的随机写和随机读,连续读和连续写没做,有兴趣的可以完善下,呵呵. //Microcontrol CODE ...