hdu 1700 Points on Cycle(坐标旋转)

http://acm.hdu.edu.cn/showproblem.php?pid=1700

Points on Cycle

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1567    Accepted Submission(s): 570

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α - y*sinα

y1=y*cosα + x*sinα

其中,x,y表示物体相对旋转点旋转角度α之前的坐标;x1,y1表示物体旋转α角后相对于旋转点的坐标

具体证明去找书吧

还有,圆周率pi要开到3.14159265才可以

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4 #include <math.h>
 5 #include <algorithm>
 6 #define eps 0.0005
 7 #define pi 3.14159265
 8 int main()
 9 {
10     int n,m,i,j;
11     scanf("%d",&n);
12     while(n--)
13     {
14         double x1,y1,x2,y2,x3,y3;
15         double Q1=pi*2/3,Q2=pi*4/3;
16         scanf("%lf%lf",&x1,&y1);
17         x2=x1*cos(Q1)-y1*sin(Q1);
18         y2=y1*cos(Q1)+x1*sin(Q1);
19         x3=x1*cos(Q2)-y1*sin(Q2);
20         y3=y1*cos(Q2)+x1*sin(Q2);//printf("%.3lf %.3lf %.3lf %.3lf\n",x2,y2,x3,y3);
21         if(fabs(y2-y3)<eps)
22         {
23             if((x2-x3)>eps)
24                 printf("%.3lf %.3lf %.3lf %.3lf\n",x3,y3,x2,y2);
25             else
26             {
27                 printf("%.3lf %.3lf %.3lf %.3lf\n",x2,y2,x3,y3);
28             }
29         }
30         else if((y2-y3)>eps)
31             printf("%.3lf %.3lf %.3lf %.3lf\n",x3,y3,x2,y2);
32         else
33             printf("%.3lf %.3lf %.3lf %.3lf\n",x2,y2,x3,y3);
34     }
35     return 0;
36 }

hdu 1700 Points on Cycle(坐标旋转)

时间: 2024-08-07 20:42:05

hdu 1700 Points on Cycle(坐标旋转)的相关文章

hdu 1700 Points on Cycle 水几何

已知圆心(0,0)圆周上的一点,求圆周上另外两点使得三点构成等边三角形. 懒得推公式,直接用模板2圆(r1=dist,r2=sqrt(3)*dist)相交水过 #include<cstdio> #include<iostream> #include<cmath> #include<algorithm> #include<iterator> using namespace std; #define eps 1e-6 typedef long lon

hdu 1700 Points on Cycle(几何)(中等)

Points on Cycle Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1992    Accepted Submission(s): 721 Problem Description There is a cycle with its center on the origin. Now give you a point on t

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

http://acm.hdu.edu.cn/showproblem.php?pid=1700 题目大意: 二维平面,一个圆的圆心在原点上.给定圆上的一点A,求另外两点B,C,B.C在圆上,并且三角形ABC的周长是最长的. 解题思路: 我记得小学的时候给出个一个定理,在园里面正多边形的的周长是最长的,这个定理我不会证明. 所以这里是三角形,当三角形为正三角形的时候,周长是最长的. 因为圆心在原点,所以我就向量(x,y)绕原点逆时针旋转120度和顺时针旋转120度.给定的点A可以看成(x,y)向量.

hdu 3934&amp;&amp;poj 2079 (凸包+旋转卡壳+求最大三角形面积)

链接:http://poj.org/problem?id=2079 Triangle Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 8173   Accepted: 2423 Description Given n distinct points on a plane, your task is to find the triangle that have the maximum area, whose vertices

暑假集训(2)第八弹 ----- Points on Cycle(hdu1700)

Points on Cycle Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u 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 th

hdu4772 坐标旋转

俩个n*n牌,问旋转0,90,180,270,时候重叠在一起一样的数最多的情况. 坐标旋转一下即可,推一下旋转公式: 如90度,回忆在坐标系中,(x,y)关于(0,0)旋转90为(-y,x),若关于(a,b),则坐标转移,把(a,b)看错原点(x-a,y-b)->(b-y,x-a),再坐标系转换回来:(b+a-y,x).在数组坐标中类似可推: #include<iostream> using namespace std; int a[35][35];int b[35][35]; int

HDU4456-Crowd (坐标旋转处理+hash处理+二维树状数组)

题意: 给出一个矩阵,初始每个位置上的值都为0,然后有两种操作 一种是更改某个位置上的值 另一种是求某个位置附近曼哈顿距离不大于K的所有位置的值的总和 技巧: 坐标旋转,使得操作之后菱形变成方方正正的矩形,(即“曼哈顿距离”转化为“切比雪夫距离”)方便使用树状数组进行计算. 利用哈希进行离散,节约空间,即不开不必要的空间. 坐标旋转: X=x-y Y=x+y 这个结果显示,A’B’C’D’(X,Y)是ABCD(x,y)绕原点(0,0)左旋转45°后的结果,同时长度变为原来的sqrt(2)倍. 由

Points on Cycle

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u 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 dis

ACM——Points on Cycle

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