题目链接:HDU 1700

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

2007省赛集训队练习赛(1)

Solution

题意

给定一个圆形在原点的圆和一个圆上的点,在圆上另外找两个点使得三个点组成的三角形周长最大。

思路

坐标旋转

坐标旋转模板题。

三角形是等边三角形是周长最大。

让给定的点绕原点旋转 \(120°\) 和 \(240°\) 即可。

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const db eps = 1e-10;
const db pi = acos(-1.0);
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll maxn = 1e5 + 10; inline int dcmp(db x) {
if(fabs(x) < eps) return 0;
return x > 0? 1: -1;
} class Point {
public:
double x, y;
Point(double x = 0, double y = 0) : x(x), y(y) {}
void input() {
scanf("%lf%lf", &x, &y);
}
bool operator<(const Point &a) const {
return (!dcmp(y - a.y))? dcmp(x - a.x) < 0: y < a.y;
}
Point Rotate(double rad) {
return Point(x * cos(rad) - y * sin(rad), x * sin(rad) + y * cos(rad));
}
}; Point ans[2]; int main() {
int T;
scanf("%d", &T);
while(T--) {
Point p;
p.input();
double r = 2.0 * pi / 3.0;
ans[0] = p.Rotate(r);
ans[1] = p.Rotate(r * 2);
sort(ans, ans + 2);
printf("%.3lf %.3lf %.3lf %.3lf\n", ans[0].x, ans[0].y, ans[1].x, ans[1].y);
}
return 0;
}

HDU 1700 Points on Cycle (坐标旋转)的更多相关文章

  1. HDU 1700 Points on Cycle(向量旋转)

    题目链接 水题,卡了下下精度. #include <cstdio> #include <iostream> #include <cmath> using names ...

  2. hdu 1700 Points on Cycle(坐标旋转)

    http://acm.hdu.edu.cn/showproblem.php?pid=1700 Points on Cycle Time Limit: 1000/1000 MS (Java/Others ...

  3. HDU 1700 Points on Cycle (几何 向量旋转)

    http://acm.hdu.edu.cn/showproblem.php?pid=1700 题目大意: 二维平面,一个圆的圆心在原点上.给定圆上的一点A,求另外两点B,C,B.C在圆上,并且三角形A ...

  4. hdu 1700 Points on Cycle 水几何

    已知圆心(0,0)圆周上的一点,求圆周上另外两点使得三点构成等边三角形. 懒得推公式,直接用模板2圆(r1=dist,r2=sqrt(3)*dist)相交水过 #include<cstdio&g ...

  5. hdu1700 Points on Cycle

    地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=1700 题目: Points on Cycle Time Limit: 1000/1000 MS ...

  6. Points on Cycle (hdu1700,几何)

    Points on Cycle Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  7. 暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)

                                                Points on Cycle Time Limit:1000MS     Memory Limit:32768 ...

  8. L - Points on Cycle(旋转公式)

    L - Points on Cycle Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u ...

  9. HDU-1700 Points on Cycle

    这题的俩种方法都是看别人的代码,方法可以学习学习,要多看看.. 几何题用到向量.. Points on Cycle Time Limit: 1000/1000 MS (Java/Others)     ...

随机推荐

  1. TI推出一款强大模拟设计与仿真工具TINA-TI 9.

    德州仪器 (TI) 宣布推出一款基于 SPICE 的强大模拟设计与仿真工具 TINA-TI 9.1.该免费软件程序的最新版本与 7.0 版相比速度平均提高 5 倍,可帮助工程师在无任何节点或器件数量限 ...

  2. HTML-参考手册: 元素和有效 DOCTYPES

    ylbtech-HTML-参考手册: 元素和有效 DOCTYPES 1.返回顶部 1. HTML 元素和有效 DOCTYPES HTML 元素 - 有效 DOCTYPES 下面的表格列出了所有的 HT ...

  3. 力扣算法——137SingleNumberII【M】

    Given a non-empty array of integers, every element appears three times except for one, which appears ...

  4. NMS python实现

    import numpy as np ''' 目标检测中常用到NMS,在faster R-CNN中,每一个bounding box都有一个打分,NMS实现逻辑是: 1,按打分最高到最低将BBox排序 ...

  5. LinkedList底层代码解析笔记

    LinkedList是属于Sequence List,故遍历是用迭代器更快; LinkedList继承自AbstractSequenceList.实现了List及Deque接口.其实AbstractS ...

  6. Java-技术专区-问题专区-应该了解的基础技术点

    Java基础 Arrays.sort实现原理和Collection实现原理 foreach和while的区别(编译之后) 线程池的种类,区别和使用场景 分析线程池的实现原理和线程的调度过程 线程池如何 ...

  7. NFS挂载error:reason given by server: Permission denied

    首先你得看看你的NFS服务有没有启动 然后你看看你要mount的文件夹有没有在NFS主机共享 然后再看权限对没对

  8. 使用JDBC获取SQL自动增长的ID

    在项目开发中,遇到一个问题,先添加一条记录然后想立刻获取这条记录的ID值,ID由SQLServer自动增长的,如果先插入再查询的话,需要另外执行一条查询ID的SQL语句,因此有了下面的方法: 1.使用 ...

  9. JS window对象 Location对象 location用于获取或设置窗体的URL,并且可以用于解析URL。 语法: location.[属性|方法]

    Location对象 location用于获取或设置窗体的URL,并且可以用于解析URL. 语法: location.[属性|方法] location对象属性图示: location 对象属性: lo ...

  10. [网络流24题] 洛谷P2761 软件补丁问题

    题意:某公司发现其研制的一个软件中有 n个错误,随即为该软件发放了一批共 m 个补丁程序.对于每一个补丁 i ,都有 2 个与之相应的错误集合 B1(i)和 B2(i),使得仅当软件包含 B1(i)中 ...