Points on cycle
Description
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
Output
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.
Sample Input
1.500 2.000
563.585 1.251
Sample Output
-280.709 -488.704 -282.876 487.453
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std; const double PI = acos(-1.0);
struct Point
{
double x, y; Point(double x = 0, double y = 0): x(x), y(y){} void scan()
{ scanf("%lf%lf", &x, &y);
} void print()
{
printf("%.3lf %.3lf", x, y);
} bool operator < (const Point &other){
return y < other.y || (y == other.y && x < other.x);
}
}; typedef Point Vector; Vector rotate(Vector A, double rad)//向量旋转公式
{
return Vector(A.x * cos(rad) - A.y * sin(rad), A.y * cos(rad) + A.x * sin(rad));
} int main()
{
int t;
Point p[3];
scanf("%d", &t);
while(t--)
{
p[0].scan(); p[1] = rotate(p[0], PI * 2 / 3);//逆时针旋转120度
p[2] = rotate(p[0], -PI * 2 / 3);//顺时针旋转120度 if(p[2] < p[1]) swap(p[1], p[2]); p[1].print(); putchar(' ');
p[2].print(); putchar('\n');
}
return 0;
}
Points on cycle的更多相关文章
- hdu 1700 Points on Cycle(坐标旋转)
http://acm.hdu.edu.cn/showproblem.php?pid=1700 Points on Cycle Time Limit: 1000/1000 MS (Java/Others ...
- HDU-1700 Points on Cycle
这题的俩种方法都是看别人的代码,方法可以学习学习,要多看看.. 几何题用到向量.. Points on Cycle Time Limit: 1000/1000 MS (Java/Others) ...
- 暑假集训(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) ...
- hdu1700 Points on Cycle
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=1700 题目: Points on Cycle Time Limit: 1000/1000 MS ...
- 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 ...
- hdu1700 Points on Cycle (数学)
Problem Description There is a cycle with its center on the origin. Now give you a point on the cycl ...
- HDU 1700 Points on Cycle (坐标旋转)
题目链接:HDU 1700 Problem Description There is a cycle with its center on the origin. Now give you a poi ...
随机推荐
- view坐标_ _ Android应用坐标系统全面详解
转:http://blog.csdn.net/yanbober/article/details/50419117 1 背景 去年有很多人私信告诉我让说说自定义控件,其实通观网络上的很多博客都在讲各种自 ...
- Nginx+Nodejs搭建图片服务器
图片上传请求由Node处理,图片访问请求由Nginx处理. 1.Nginx配置 #user nobody; worker_processes 1; #error_log logs/error.log; ...
- XMPP协议错误码
302 重定向 尽管HTTP规定中包含八种不同代码来表示重定向,Jabber只用了其中一个(用来代替所有的重定向错误).不过Jabber代码302是为以后的功能预留的,目前还没有用到 400 坏请求 ...
- PHP如何获取文件行数
本文实例讲述了PHP获取文件行数的方法.分享给大家供大家参考.具体分析如下:提供两种实现方法,虽然第二种简单易懂,但是第一种效率最好第一种: <?php $file_path = 'xxx.tx ...
- out参数,ref参数,params参数数组
params参数数组 params关键字可以为方法指定数目可变的参数.params关键字修饰的参数,可以传入任意数目的同类型参数,甚至可以不传入参数. 不过params修饰的参数必须是方法的最后一个参 ...
- MySQL绿色版5.7以上安装教程
写在前面:5.7增加了安全性,默认root密码不在为空,而是初始化时随机生成一个root密码,改root密码的方式也不一样了 下载地址 http://dev.mysql.com/downloads/m ...
- lua 基础库
数学库: 三角函数:math.sin, math.cos, math.tan, math.asin, math.acos 都以弧度为单位: 指数和对数函数:exp, log, log10: 取整函数: ...
- Device Path in WinPrefetchView
As we know that the Prefetch file is used for optimizing the loading time of the application in the ...
- SQL笔记-第四章,数据的检索
一.select的简单用法 1.简单的数据检索 SELECT * FROM T_Employee; 2.检索出需要的列 SELECT FNumber,FName,FAge FROM T_Employe ...
- JavaScript入门
本篇内容是学习慕课网相关课程后,总结出可能未来会忘记的内容 (一)JavaScript入门操作 1.js代码插入位置,以及执行顺序 <head> <script type=" ...