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. visual studio中验证控件的使用

    1.RequiredFieldValidator:验证一个必填字段,如果这个字段没填,那么,将不能提交信息. RequiredFieldValidator控件中,主要设置三个属性: (1)ErrorM ...

  2. 我摘录的js代码

    1.修改样式 document.getElementByIdx( "div1").style.display = "none"; 2.鼠标悬停图标变小手 sty ...

  3. pkg-config相关的常用指令

    pkg-config用途: 查询系统已安装库的基础信息(元信息) 1.查看所有的pkg-config库 pkg-config --list-all --list-all  列出pkg-config路径 ...

  4. linux配置记录

    今天想把开发环境都配置到linux环境来,所以用wubi挂载了个ubuntu系统(64位),因为不常使用linux所以把今天学到的一些 东西记下来以做备查. #1.   java环境配置 到oracl ...

  5. Nopcommerce架构浅谈之文件结构

    应该是在两年前了,在拜读园子里大神的文章时偶然了解到有个叫NopCommerce的商城系统,苦于没有时间,各种耽误,其中研究过一段时间,也就是一个星期时间,后来又耽搁了,直到最近,随着项目进入间歇期, ...

  6. C# asp:Repeater DataSource List<T>

    1. asp:Repeater 数据源为List<T> 2.页面显示 3.行绑定取值

  7. Java中间件

    传统的HTML已经满足不了如今web系统的诸多的功能需求,建立一个交互式的Web,便诞生了各种Web开发语言,如ASP,JSP,PHP等,这些语言与传统的语言有着密切的联系,如JSP基于Java语言. ...

  8. Solr4.8.0源码分析(26)之Recovery失败造成的宕机原因分析

    最近在公司做SolrCloud的容灾测试,刚好碰到了一个比较蛋疼的问题,跟SolrCloud的Recovery和leader选举有关,正好拿出来分析下. 现象是这样的:比如我有一台3个shard的So ...

  9. 转:2014年最酷的30个JavaScript库

    原文来自于:http://www.gbtags.com/gb/share/3701.htm 使用JavaScript库将会使开发变的更简单,大部分JavaScript库提供的功能都是极好的,当我们在为 ...

  10. linux vi查找命令

    linux vi查找命令   div id="article_content" class="article_content">  使用vi编辑器编辑长文 ...