HDU-1700 Points on Cycle
来源:互联网 发布:mac 相对于卷宗的格式 编辑:程序博客网 时间:2024/06/05 06:08
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
题解:用向量旋转公式:x1=x*cos(A)-y*sin(A),y1=x*sin(A)+y*cos(A). (x,y)为已知向量,A为旋转角度。
#include<iostream>#include<cmath>using namespace std;#define PI acos(-1.0)struct Point { double x, y;};Point Rotate(Point A, double angle){ Point B; B.x = A.x*cos(angle) - A.y*sin(angle); B.y = A.x*sin(angle) + A.y*cos(angle); return B;}void sswap(Point &m, Point &n){ Point w; if (m.y < n.y)return; else if (m.y > n.y) { w = m;m = n;n = w; } else { if (m.x <= n.x)return; else { w = m; m = n; n = w; } }}int main(){ int T; cin >> T; while (T--) { Point A, B, C; cin >> A.x >> A.y; B = Rotate(A, PI * 2 / 3); C = Rotate(A, -PI * 2 / 3); sswap(B, C); printf("%.3lf %.3lf %.3lf %.3lf\n", B.x, B.y, C.x, C.y); } return 0;}
- HDU 1700 Points on Cycle
- HDU-1700 Points on Cycle
- hdu 1700 Points on Cycle 水几何
- hdu 1700 Points on Cycle(几何)(中等)
- 【计算几何】 HDOJ 1700 Points on Cycle
- HDU1700:Points on Cycle
- HDU 1700 || Points on Cycle (向量旋转,圆上等边三角形的周长最长
- hdu1700 Points on Cycle (数学)
- HDU1700 Points on Cycle(感觉很重要)
- hdu 1700 Points on circle(三角函数应用)
- HDU1700 Points on Cycle (最大内接三角形)
- codeforces251A. Points on Line
- CF251A. Points on Line
- codeforces251A. Points on Line
- Array Points on Surface
- HDU1700Points on Cycle
- HDU Clarke and points
- The Moving Points HDU
- MFC多文档程序启动时一个文档创建两个视图
- linux下ioctl()函数使用的详细说明
- PHP常量详解:define和const的区别
- C++中一个空类含有哪些默认的成员函数
- 较长输入行折成多行
- HDU-1700 Points on Cycle
- 面试题30:最小的k个数
- java算法之身份证号码验证
- 1479 小Y的数论题
- 起航
- javaScript笔记(九) 变量、作用域及内存
- java学习之路 之 高级类特性1-面向对象特征之三:多态
- C# 扩展方法
- java操作连接mysql