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
     

问题分析:它是一道几何题,假设以知点a坐标为(x0,y0),位置点b,c为(x1,y1),(x2,y2).  圆方程为x2+y2 = r2;可将圆方程化为x=rcosα,y=rsinα;

又有x12+y1 2= r2 = x02+y0 2,(a*b)/|a|*|b| = cos120

易得 acosα + bsinα = -0.5r

(acosα)2   = (0.5r + bsinα)2

r2sinα2 + rbsinα + 0.25r2 - a2 = 0

得   x1 = -0.5*b + a*√3 * 0.5  或 x1 = -0.5*b - a*√3 *0.5(舍去)

及   y = -0.5*b - a*√3 * 0.5  或 y= 0.5*b + a*√3 * 0.5(舍去)

同理可得x2,y2

也可直接利用cos(α+β) = cosαcosβ - sinαsinβ ,sin(α+β) = sinαcosβ + cosαsinβ求解,

 #include <cstdio>
#include <cmath>
int main()
{
double a,b,x0,y0,x1,y1,x2,y2;
int t;
a=sqrt(3.0)/;
b=-0.5;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf",&x0,&y0);
x1 = b*x0 - a*y0;
y1 = b*y0 + a*x0;
x2 = b*x0 + a*y0;
y2 = b*y0 - a*x0;
if(y1<y2 || ((fabs(y1-y2) < 0.005) && x1 < x2))
printf("%.3lf %.3lf %.3lf %.3lf\n",x1,y1,x2,y2);
else
printf("%.3lf %.3lf %.3lf %.3lf\n",x2,y2,x1,y1);
}
return ;
}
 

暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)的更多相关文章

  1. 2016HUAS暑假集训训练2 L - Points on Cycle

    题目链接:http://acm.hust.edu.cn/vjudge/contest/121192#problem/L 这是一道很有意思的题,就是给定一个以原点为圆心的圆,然后给定 一个点  求最大三 ...

  2. 暑假集训(3)第二弹 -----Jungle Roads(Hdu1301)

    问题梗概:自从上次某个acmer来设计了拉格瑞圣岛的交通路线后,岛上的酋长就相当苦恼,他发现,虽然这些修好的公路便利了岛上的 交通,并且让拉格瑞圣岛的旅游业更加兴旺,甚至他们还收到了一笔不小的国际资金 ...

  3. 暑假集训(1)第二弹 -----Catch the cow(Poj3278)

    Description Farmer John has been informed of the location of a fugitive cow and wants to catch her i ...

  4. 暑假集训(5)第二弹———湫湫系列故事——减肥记I(hdu4508)

    问题描述:舔了舔嘴上的油渍,你陷在身后柔软的靠椅上.在德源大赛中获得优胜的你,迫不及待地赶到“吃到饱”饭店吃到饱.当你 正准备离开时,服务员叫住了你,“先生,您还没有吃完你所点的酒菜.”指着你桌上的一 ...

  5. 暑假集训(5)第一弹——— Super Jumping! Jumping! Jumping!(hdu1087)

    题意概括:在上次与娑殚的三次博弈中,你们都取得了胜利.便向娑殚提出要求,借助他的力量,传送到一个安全的地方. 你们的愿望达成了,不过,你和小A似乎失散了. 街上人来人往的特别热闹,每一个人的脸上都洋溢 ...

  6. 暑假集训(4)第二弹 -----递推(hdu2254)

    题意概括:上次小A在你的帮助下成功炼成贤者法阵的第一部分——三角分隔,现在他准备绘制法阵的第二部分——莫测矩形. 而他又遇到了一个问题,他不知道不同矩形到底有多少个. 秉持帮人帮到底,送佛送到西的基本 ...

  7. 暑假集训(4)第一弹 -----递推(Hdu2039)

    题意梗概:fff团团员小A想退团了,不过要退团,他必须绘制出贤者法阵,以证明他有资格不受大fff之灵的监督 并退团,小A他现在要开始收集材料了,但是,他不清楚应该买多少份材料. 虽然你并不想帮他退团, ...

  8. 暑假集训(3)第一弹 -----还是畅通工程(hdu1233)

    题意梗概:N(n<100)个村子想要富起来,自然就要先修路,不过到底还是没富起来,所以陷入了一个怪圈 :资金不足->修不起路->资金不足...... 为了实现走向全民小康社会,全面实 ...

  9. 暑假集训(2)第二弹 ----- The Suspects(POJ1611)

    B - The Suspects Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:20000KB   ...

随机推荐

  1. Storm系列(十六)架构分析之Executor-Bolt

    准备消息循环的数据 函数原型: 1  let[executor-sampler (mk-stats-sampler (:storm-conf executor-data))] 主要功能: 定义tupl ...

  2. HW1.5

    public class Solution { public static void main(String[] args) { System.out.println("(9.5 * 4.5 ...

  3. 为静态Checkbox动态地添加checked属性

    1.ASP.NET HTML Code: 嵌套在repeater中 " ? "checked" : "" %> /> *** 关键代码: ...

  4. 【Mysql学习笔记】浅析mysql的binlog

    最近读一份关于“数据库事务故障恢复"的技术资料,发现对mysql的binlog的认识不够清楚,查阅mysql reference manual有所收获,作为笔记,记录于此. 1. What' ...

  5. 大型机汇编(mainframe assembler/HLASM)之COBOL解惑

    IDENTIFICATION DIVISION.             PROGRAM-ID. HELLO.                   ENVIRONMENT DIVISION.      ...

  6. scrollTop 值为 0

    由scrollTop兼容问题引起: 在 Firefox 和 IE 中,使用 document.documentElement.scrollTop 获取: 在 Chrome 中,使用 document. ...

  7. Redis集群方案应该怎么做

    方案1:Redis官方集群方案 Redis Cluster Redis Cluster是一种服务器sharding分片技术.Redis Cluster集群如何搭建请参考我的另一篇博文:http://w ...

  8. 高质量CSS编写规范

    ①id和class的命名在保持语义性的同时尽可能的短.不推荐的写法:#navigation {} .atr {}推荐的写法  : #nav {} .author {}可以缩写单词,但缩写后务必能让人明 ...

  9. C#泛型比较大小

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  10. C#数据类型中的decimal精度比double更高

    decimal 128bit大小 有效数字:28~29,虽然decimal类型有比浮点类型更高的精度,但它的范围更小.故double转decimal有可能发生溢出错误,此外,decimal的计算速度稍 ...