• 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

    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
    ", ans[0].x, ans[0].y, ans[1].x, ans[1].y);
        }
        return 0;
    }
    
  • 相关阅读:
    oraToolKit Oracle安装辅助工具的使用方法
    oraToolKit Oracle安装辅助工具的使用方法
    创建Oracle数据库、数据库名与实例名与SID之间的关系(图文详解)
    创建Oracle数据库、数据库名与实例名与SID之间的关系(图文详解)
    RHEL6.1 安装 Oracle10gr2 (图文、解析)
    RHEL6.1 安装 Oracle10gr2 (图文、解析)
    14.1.3 Turning Off InnoDB 关掉InnoDB
    zabbix 获取jvm session信息
    Mysql 执行计划分析
    mysql 执行计划走索引
  • 原文地址:https://www.cnblogs.com/wulitaotao/p/11604834.html
Copyright © 2020-2023  润新知