地址: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 ;
}

最新文章

  1. Linux C 字符串函数 sprintf()、snprintf() 详解
  2. linux基础
  3. poj1847 最短路
  4. win10使用小技巧以及常见问题处理方案
  5. JVM垃圾回收机制总结(5) :JDK垃圾收集器的配置命令
  6. Activity之间使用intent传递大量数据带来问题总结
  7. ASP.NET在主题中添加CSS文件
  8. PHP 中的超全局变量
  9. CSS 设计彻底研究(三)深入理解盒子模型
  10. 深入浅出:重温JAVA中接口与抽象的区别
  11. 1、第一个Struts2程序
  12. jsoup 解析html
  13. Python 总结
  14. 印象之初:BugPhobia’s Brief Introduction
  15. MIME Types - Complete List
  16. Hbase框架原理及相关的知识点理解、Hbase访问MapReduce、Hbase访问Java API、Hbase shell及Hbase性能优化总结
  17. POJ 3268 Silver Cow Party 最短路径+矩阵转换
  18. HTML5之2D物理引擎 Box2D for javascript Games 系列 第一部分
  19. vue-router与v-if实现tab切换的思考
  20. 跟着百度学PHP[17]-PHP扩展CURL的用法详解

热门文章

  1. python远程登录服务器(paramiko模块安装和使用)
  2. cocos2d-x游戏引擎核心之十——网络通信
  3. 《转》python学习(7) -列表
  4. 我觉得epoll和select最大的区别
  5. 使用Sublime Text 3做Python开发
  6. Git学习笔记(SourceTree克隆、提交、推送、拉取等)
  7. IOS项目分层
  8. 三维凸包求凸包表面的个数(HDU3662)
  9. linix防火墙设置之顺序设置问题 -- 解决防火墙规则顺序和插入规则到指定序号的问题
  10. Hibernate的状态,缓存和映射