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. ural 1091. Tmutarakan Exams 和 codeforces 295 B. Greg and Graph

    ural 1091 题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1091 题意是从1到n的集合里选出k个数,使得这些数满足gcd大于1 ...

  2. Spark RDD概念学习系列之RDD的容错机制(十七)

    RDD的容错机制 RDD实现了基于Lineage的容错机制.RDD的转换关系,构成了compute chain,可以把这个compute chain认为是RDD之间演化的Lineage.在部分计算结果 ...

  3. linux中vi/vim显示行号设置

    vim打开文件是,默认不提示行号. 至于显示行号的用途,因人而异 临时修改只需要在编辑文件时输入 :set number 即可 linux下一个主机可能有N个账户.对于配置分为两种:仅配置当前账户,配 ...

  4. jquery判断文本域长度

    <div id="result">您还可以输入100字</div> <textarea name="content" id=&qu ...

  5. mysql繁字体报错,Incorrect string value: '\xE9_' for column 'UserName' at row 1

    mysql 插入繁体字的时候报错,然后网上找了,说是mysql的库设置为character-set = utf8mb4 结果设置还是没效果 搞了好几天都不知道什么原因,然后今天想了想,好像之前有个学长 ...

  6. eclipse加入git工具

    想必如今搞互联网编程的人没有人没有听过编程协作工具git了吧,命令行以下操作很方便.功能也很的强大. 可是对于java编程的人员,eclipse肯定是他们编程的神器(肯定是首选), 那么怎样在ecli ...

  7. dmesg 程序崩溃调试

    [root@localhost log]# cat -n /root/xx.c #include <stdio.h> void func(char *p) { *p = 'p'; } in ...

  8. Android 接收短信

    启动程序时启动一个service,在service里注册接收短信的广播,当手机收到短信里,打印出短信内容跟电话号码. package com.lmy.SmsListener; import andro ...

  9. 谈谈Javascript线程

          其实,大家都知道Javascript的语言执行环境是单线程的,浏览器无论在什么时候都有且只有一个线程在运行Javascript程序.那Ajax发送异步请求怎么解释,setTimeout/s ...

  10. POJ1329题

    Circle Through Three Points Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Jav ...