hdu1700 Points on Cycle
地址: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
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.
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.
when output, if the absolute difference between the coordinate values X1 and X2 is smaller than 0.0005, we assume they are equal.
1.500 2.000
563.585 1.251
-280.709 -488.704 -282.876 487.453
思路:
直接猜是等边三角形,然后发现确实是。
求其他两个点,直接旋转就行了。
#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的更多相关文章
- HDU-1700 Points on Cycle
这题的俩种方法都是看别人的代码,方法可以学习学习,要多看看.. 几何题用到向量.. Points on Cycle Time Limit: 1000/1000 MS (Java/Others) ...
- hdu1700 Points on Cycle (数学)
Problem Description There is a cycle with its center on the origin. Now give you a point on the cycl ...
- 暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)
Points on Cycle Time Limit:1000MS Memory Limit:32768 ...
- Points on Cycle (hdu1700,几何)
Points on Cycle Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu 1700 Points on Cycle(坐标旋转)
http://acm.hdu.edu.cn/showproblem.php?pid=1700 Points on Cycle Time Limit: 1000/1000 MS (Java/Others ...
- L - Points on Cycle(旋转公式)
L - Points on Cycle Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- HDU1700:Points on Cycle
Problem Description There is a cycle with its center on the origin. Now give you a point on the cycl ...
- Points on cycle
Description There is a cycle with its center on the origin. Now give you a point on the cycle, you a ...
- HDU 1700 Points on Cycle (坐标旋转)
题目链接:HDU 1700 Problem Description There is a cycle with its center on the origin. Now give you a poi ...
随机推荐
- 【RF库Collections测试】Get From Dictionary
Name:Get From DictionarySource:Collections <test library>Arguments:[ dictionary | key ]Returns ...
- Python3 urllib 库
urllib 简介 urllib 基础模块 使用 urllib 发送请求 使用 urllib 构造请求对象 关于 Handler 与 opener 使用 urllib 进行身份验证 使用 urllib ...
- C++11新特性之三——auto
C++11中引入的auto主要有两种用途:自动类型推断和返回值占位.auto在C++98中的标识临时变量的语义,由于使用极少且多余,在C++11中已被删除.前后两个标准的auto,完全是两个概念 1. ...
- 定义了一个UIImageView如何使加载的图片不会失真 UIImageView的Frame值是固定的
定义了一个UIImageView如何使加载的图片不会失真 UIImageView的Frame值是固定的 UIViewContentModeScaleToFill, 缩放内容到合适比例大小 UIVie ...
- ios 读取各种类型文件
1.如何读取UTF-8编码的文本文件? 2.如何读取GB2312(中文)的文本文件? 3.如何读取其它编码文件? 首先解决第一个问题, 1.如何读取UTF-8编码的文本文件? NSString *fi ...
- Django学习笔记 开发环境搭建
为什么使用django?1.支持快速开发:用python开发:数据库ORM系统,并不需要我们手动地构造SQL语句,而是用python的对象访问数据库,能够提升开发效率.2.大量内置应用:后台管理系统a ...
- Java中UDP协议的基本原理和简单用法
UDP协议是非面向连接的,相对于TCP协议效率较高,但是不安全.UDP协议类似发信息的过程,不管接收方是在线还是关机状态,都会把信息发送出去.但是如果接收方不处于接收信息的状态,发送出去的数据包就会丢 ...
- Asp SqlDataSource将数据库数据绑定在 GridView
1.首先认识一下GridView的几条属性 ☻AllowPaging 确定是否可以分页 ☻AllowSorting 确定是否可以进行排序 ☻AlternatingRowStyle 指定奇数行样式 ...
- 解决Activity启动黑屏及设置android:windowIsTranslucent不兼容activity切换动画问题
From:http://blog.csdn.net/fancylovejava/article/details/39643449 之前在做 APP 的时候不太关注这个问题,因为自己在使用其他 APP ...
- idea的svn插件中compare with the same repository version和compare with latest repository version的区别?
Idea的svn插件中compare with the same repository version和compare with latest repository version的区别? 1.com ...