HDU 1700 Points on Cycle (坐标旋转)
题目链接: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
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 (坐标旋转)的更多相关文章
- HDU 1700 Points on Cycle(向量旋转)
		题目链接 水题,卡了下下精度. #include <cstdio> #include <iostream> #include <cmath> using names ... 
- 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 (几何 向量旋转)
		http://acm.hdu.edu.cn/showproblem.php?pid=1700 题目大意: 二维平面,一个圆的圆心在原点上.给定圆上的一点A,求另外两点B,C,B.C在圆上,并且三角形A ... 
- hdu 1700 Points on Cycle 水几何
		已知圆心(0,0)圆周上的一点,求圆周上另外两点使得三点构成等边三角形. 懒得推公式,直接用模板2圆(r1=dist,r2=sqrt(3)*dist)相交水过 #include<cstdio&g ... 
- hdu1700 Points on Cycle
		地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=1700 题目: Points on Cycle Time Limit: 1000/1000 MS ... 
- Points on Cycle  (hdu1700,几何)
		Points on Cycle Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ... 
- 暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)
		Points on Cycle Time Limit:1000MS Memory Limit:32768 ... 
- L - Points on Cycle(旋转公式)
		L - Points on Cycle Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ... 
- HDU-1700         Points on Cycle
		这题的俩种方法都是看别人的代码,方法可以学习学习,要多看看.. 几何题用到向量.. Points on Cycle Time Limit: 1000/1000 MS (Java/Others) ... 
随机推荐
- python进阶:类和对象
			@修饰符:将被修饰的函数作为参数,运行修饰函数 实例方法: 静态方法:@staticmethod 类方法:@classmethod 自省:通过一定的机制查询到对象的内部结构 序列类: 列表推导式(例表 ... 
- 关于自动化测试学习   selenium
			selenium学习路线 配置你的测试环境,真对你所学习语言,来配置你相应的selenium 测试环境.selenium 好比定义的语义---“问好”,假如你使用的是中文,为了表术问好,你的写法是“你 ... 
- Linux随笔 - DNS搭建
			域名系统(英文:Domain Name System,缩写:DNS)是因特网的一项服务.它作为将域名和IP地址相互映射的一个分布式数据库,能够使人更方便的访问互联网.DNS 使用TCP和UDP端口53 ... 
- Spring事物的传播
			spring的事物对于同一个类内部调用是不会生效的. 比如一个ServiceA,里面有个方法x()和y().其中x没有配置事物,而y配置的有实物.如果是一个没有事物的ServiceB调用了Servic ... 
- 【转】开源框架是如何通过JMX来做监控的(一) - JMX简介和Standard MBean
			原文链接:https://www.cnblogs.com/trust-freedom/p/6842332.html#autoid-0-0-0 相信很多做Java开发的同学都使用过JDK自带的 jcon ... 
- MVC路由解析---UrlRoutingModule
			文章引导 MVC路由解析---IgnoreRoute MVC路由解析---MapRoute MVC路由解析---UrlRoutingModule Area的使用 引言: 此文全文内容90%转自 一.前 ... 
- 第四周总结和实验二Java简单类与对象
			实验目的 掌握类的定义,熟悉属性.构造函数.方法的使用,掌握用类作为类型声明变量和方法返回值: 理解类和对象的区别,掌握构造函数的使用,熟悉通过对象名引用实列的方法和属性: 理解static修饰对类. ... 
- Jmeter+ InfluxDB+Grafana安装配置
			前置条件: 系统:windows jmeter:5.1 InfluxDB安装 下载InfluxDB-v1.7.9和Chronograf-v1.7.14(InfluxDB的可视化web端). 下载完成之 ... 
- Spring Cloud配置中心高可用搭建
			本文通过config server连接git仓库来实现配置中心,除了git还可以使用svn或者系统本地目录都行. 引入依赖 <dependencies> <dependency> ... 
- css3新增(圆角边框(border-radius),盒子阴影(box-shadow),文字阴影(text-shadow),背景缩放(background-size))
			1.圆角边框 border-radius border-radius 属性用于设置元素的外边框圆角 语法:border-radius:length; 参数值可以是数值 或者 百分比 的形式 正方形, ... 
