地址: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. ajax异步加载回跳定位

    1)首先,问题是这样的:page1在一个滚动到页面底部加载更新的函数(功能),当页面滚动了第二页(或更多页)时,点击链接跳转到了其他页面(page2),在page2有返回按钮,当从page2返回pag ...

  2. Windows下重置Mysql密码

    1.首先停止正在运行的MySQL进程 >net stop mysql 如未加载为服务,可直接在进程管理器或者服务中进行关闭. 2.以安全模式启动MySQL进入mysql目录在命令行下运行 > ...

  3. PHP之变量范围

    前面的话 变量范围即它定义的上下文背景(也就是它的生效范围).在javascript中,并没有变量范围这一概念,相似的可能是作用域.但是,由于javscript使用的是词法作用域,指变量声明时的位置: ...

  4. 开源的PaaS方案:在OpenStack上部署CloudFoundry (二)部署OpenStack

    硬件要求 安装OpenStack 1 安装CentOS 65系统并清空iptables防火墙规则 2 安装系统需要的工具包包括Openstack依赖的和CloudFoundry依赖的 3 安装EPEL ...

  5. HTML - 分页效果布局

    <p class="jcFY"> 显示 <select name="" id=""> <option valu ...

  6. libvirt kvm 虚拟机上网 – Bridge桥接

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

  7. Excel 2010 统计行数

    1. 首先选择一个空行 2.然后点击如下:公式 --- 3. 第一行:填写“103”,当然我也不能明白为啥填写103.照做就是了. 4.鼠标定位到 第二行 “Ref1”位置,然后 鼠标+shfit 按 ...

  8. 【APIO2016】Fireworks[DP 可并堆维护凸包优化]

    4585: [Apio2016]烟火表演 Time Limit: 40 Sec  Memory Limit: 256 MBSubmit: 100  Solved: 66[Submit][Status] ...

  9. scss语法

    SCSS其实就是SASS新语法, 增强了对CSS3语法的支持 1.变量(Variables) /*声明变明*/ $color: #333; $bgcolor:#f36; /*引用变量*/ body { ...

  10. C++ XML 序列化器

    http://www.cppblog.com/xlshcn/archive/2007/11/21/cppxmlserializer.html