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
 
 
题目大意:
     给出圆上一点求出该园上任选两点使任意该三角形周长。
 
解题思路:
      最长明显为正三角形周长最长,这题可以用向量旋转公式做,也可以用普通的数学式做。以下给出用向量旋转解题的方法。
 
代码如下:

#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std; const double PI = acos(-1.0);
struct Point
{
double x, y; Point(double x = 0, double y = 0): x(x), y(y){} void scan()
{ scanf("%lf%lf", &x, &y);
} void print()
{
printf("%.3lf %.3lf", x, y);
} bool operator < (const Point &other){
return y < other.y || (y == other.y && x < other.x);
}
}; typedef Point Vector; Vector rotate(Vector A, double rad)//向量旋转公式
{
return Vector(A.x * cos(rad) - A.y * sin(rad), A.y * cos(rad) + A.x * sin(rad));
} int main()
{
int t;
Point p[3];
scanf("%d", &t);
while(t--)
{
p[0].scan(); p[1] = rotate(p[0], PI * 2 / 3);//逆时针旋转120度
p[2] = rotate(p[0], -PI * 2 / 3);//顺时针旋转120度 if(p[2] < p[1]) swap(p[1], p[2]); p[1].print(); putchar(' ');
p[2].print(); putchar('\n');
}
return 0;
}

  

Points on cycle的更多相关文章

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

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

  2. HDU-1700 Points on Cycle

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

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

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

  4. Points on Cycle (hdu1700,几何)

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

  5. hdu1700 Points on Cycle

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

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

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

  7. HDU1700:Points on Cycle

    Problem Description There is a cycle with its center on the origin. Now give you a point on the cycl ...

  8. hdu1700 Points on Cycle (数学)

    Problem Description There is a cycle with its center on the origin. Now give you a point on the cycl ...

  9. HDU 1700 Points on Cycle (坐标旋转)

    题目链接:HDU 1700 Problem Description There is a cycle with its center on the origin. Now give you a poi ...

随机推荐

  1. bootstrap-面板、modal

    面板: <!-- panel 面板 panel-heading 面板头部 panel-title 面板标题样式 panel-body 面板内容 --> <div class=&quo ...

  2. Python绑定方法,未绑定方法,类方法,实例方法,静态方法

    >>> class foo(): clssvar=[1,2] def __init__(self): self.instance=[1,2,3] def hehe(self): pr ...

  3. Quartus II中FPGA的管脚分配保存方法

    一.摘要 将Quartus II中FPGA管脚的分配及保存方法做一个汇总. 二.管脚分配方法 FPGA 的管脚分配,除了在QII软件中,选择“Assignments ->Pin”标签(或者点击按 ...

  4. SQLite页缓冲区管理

    页面管理器是访问本地数据库文件和日志文件的唯一模块(通过操作系统API).但是它不对数据库的内容做解析,也不对数据库内容做修改(但是页管理器会对文件头信息部分内容做修改).它把随机访问系统或面向字节的 ...

  5. 30. PL/SQL Developer连接服务器查询时,数据乱码处理

    在windows中创 建一个名为“NLS_LANG”的系统环境变量,设置其值为"AMERICAN_AMERICA.ZHS16GBK",   NLS_LANG的值为:select u ...

  6. 利用jquery实现自动登录

    前提是需要引入jquery和jquery.cookie html 用户名:<input type="text" id="name"/><br ...

  7. jquery表格增加删除后改变序号

    有个小bug,懒得修了. 目的:增加一行的时候,td第一列排序. 删除一行的时候,td第一列排序 <!DOCTYPE HTML> <html> <head> < ...

  8. dubbo 使用总结

    第一步: 安装注册中心Register,这里选择 zookeeper 1.zookeeper下载url:http://zookeeper.apache.org; 2.下载解压完后如下: 3.将zoo_ ...

  9. 编程范式 epesode7,8 stack存放指针类型and heap,register

    这一节从后往前写. ____stack and heap ___stack由 汇编语言操控管理,数据先入后出. 栈是存放局部变量,函数调用子函数时,该函数在栈中占用的空间会增大,用于存放子函数的局部变 ...

  10. arcgis desktop按ctrl键后地图乱移的解决办法

    习惯使用快捷键的,经常会按下ctrl. 但在arcmap中,按下ctrl后,地图乱移.分析发现变为鼠标导航状态,也就是鼠标偏离地图中心,地图就会往鼠标所在方向移动. 解决办法:1. 以前按下esc键, ...