地址: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. SDRAM容量的计算方法

    当我在看有关SDRAM的芯片手册的时候,我一直在想这样一个问题:SDRAM的容量它究竟是如何计算的呢?经过查找网上的各种资料,最后在这里给大伙分享一下我的总结! 就以我的开发板的SDRAM的芯片手册的 ...

  2. 《C++ Primer Plus》15.5 类型转换运算符 学习笔记

    C++相对C更严格地限制允许的类型转换,并添加4个类型转换运算符,是转换过程更规范:* dynamic_cast:* const_cast:* static_cast:* reinterpret_ca ...

  3. Solr服务搭建

    1.1. Solr的环境 Solr是java开发. 需要安装jdk. 安装环境Linux. 需要安装Tomcat. 1.2. 搭建步骤 第一步:把solr 的压缩包上传到Linux系统 第二步:解压s ...

  4. LeetCode——Reverse Linked List

    反转链表,用了一个比较笨的方法. public class Solution { public ListNode reverseList(ListNode head) { if(head == nul ...

  5. .net asp [转载]ASP:循环滚动图片的代码+解释

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. R测试向量是否相等

    > x<-1:3 > typeof(x) [1] "integer" > y<-c(1,3,4) > typeof(y) [1] "d ...

  7. 有关velocity的资料(等待整理)

    proxy-target-class="true" 与proxy-target-class="false"的区别: proxy-target-class属性值决 ...

  8. mysql中or和in的效率问题

    分三中情况进行测试,分别是:第一种情况:in和or所在列为主键的情形.第二种情况:in和or所在列创建有索引的情形.第二种情况:in和or所在列没有索引的情形.每种情况又采用不同的in和or的数量进行 ...

  9. Yii 获取url 的一些方法

    原文出处http://blog.csdn.net/iefreer/article/details/21325371 1. 获取url中的host信息: Yii::app()->request-& ...

  10. Allocation Sinking Optimization

    LuaJIT Sponsorship Program http://luajit.org/sponsors.html Sponsorship for allocation/store sinking ...