地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=1700

题目:

Points on Cycle

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2523    Accepted Submission(s): 972

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
 
Source
 
Recommend
lcy

思路:

  直接猜是等边三角形,然后发现确实是。

  求其他两个点,直接旋转就行了。

 #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm> using namespace std;
const double PI = acos(-1.0);
const double eps = 5e-; /****************常用函数***************/
//判断ta与tb的大小关系
int sgn( double ta, double tb)
{
if(fabs(ta-tb)<eps)return ;
if(ta<tb) return -;
return ;
} //点
class Point
{
public: double x, y; Point(){}
Point( double tx, double ty){ x = tx, y = ty;} };
//两点间距离
double getdis(const Point &st,const Point &se)
{
return sqrt((st.x - se.x) * (st.x - se.x) + (st.y - se.y) * (st.y - se.y));
} int main(void)
{
//freopen("in.acm","r",stdin);
int t;
scanf("%d",&t);
Point pa,pb,pc,pp=Point(,);
while(t--)
{
scanf("%lf%lf",&pa.x,&pa.y);
double r = getdis(pa,pp);
double ag = atan2(pa.y,pa.x);
pb.x = r * cos(ag + PI * / ), pb.y = r * sin(ag + PI * / );
pc.x = r * cos(ag - PI * / ), pc.y = r * sin(ag - PI * / );
if(sgn(pb.y,pc.y)>||(sgn(pb.y,pc.y)==&&sgn(pb.x,pc.x)>))
swap(pb,pc);
printf("%.3f %.3f %.3f %.3f\n",pb.x,pb.y,pc.x,pc.y);
}
return ;
}

hdu1700 Points on Cycle的更多相关文章

  1. HDU-1700 Points on Cycle

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

  2. hdu1700 Points on Cycle (数学)

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

  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. laravel 发送邮件

    1)邮件配置(config/mail.php 配置文件) MAIL_DRIVER                       邮箱驱动,laravel 支持 "smtp", &qu ...

  2. 安装autoit libary失败问题解决

    运行环境:win7-32,python2.7安装遇到的问题:

  3. Python 入门(四)List和Tuple类型

    创建list Python内置的一种数据类型是列表:list.list是一种有序的集合,可以随时添加和删除其中的元素. 比如,列出班里所有同学的名字,就可以用一个list表示: >>> ...

  4. PL/SQL编程1-基础

    编写第一个存储过程 create or replace procedure test_pro1 is begin ','zydev'); end; / 查看错误 show error 执行存储过程 e ...

  5. 说说FATFS文件系统(转)

    FATFS是一个为小型嵌入式系统设计的通用FAT(File Allocation Table)文件系统模块.FatFs 的编写遵循ANSI C,并且完全与磁盘I/O层分开.因此,它独立(不依赖)于硬件 ...

  6. 腾讯云CMQ消息队列在Linux环境下的使用

    版权声明:本文由李少华原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/76 来源:腾云阁 https://www.qclou ...

  7. 关于Android图片资源瘦身的奇思妙想

    版权声明:本文由况鹰原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/77 来源:腾云阁 https://www.qcloud ...

  8. jstl标签怎么实现分页中下一页

    <script type="text/javascript">           //分页按钮处理        function goPageAction(page ...

  9. 键盘event.which属性

    IE中,只有keyCode属性,而FireFox中有which和charCode属性 event.which属性对DOM原生的event.keyCode和event.charCode进行了标准化. f ...

  10. [分享]收集的Linux学习资源

    下面是我收集的一些Linux资源,与大家分享.大家共同学习,一起进步. 国内的专业Linux网站(GB) 1. ChinaUnix:http://www.chinaunix.net/ 2. Linux ...