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. Python招聘需求与技能体系

    目前国内的招聘Python,基本都是偏向web后台开发,偶有高大上的数据挖掘&机器学习. 这是之前(2012年)找工作整理的一些JD,在梳理几年来的笔记,顺带理一理 可以以此建立自己的技能体系 ...

  2. Android 通过按钮弹出系统菜单(通过Button显示菜单)转

    myButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { openOpti ...

  3. [ActionScript 3.0] AS3.0 涂鸦及擦除功能,撤销重做步骤记录实例

    package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.BlendMo ...

  4. (转)SVN 服务端、客户端安装及配置、导入导出项目

    SVN服务器搭建和使用(一) Subversion是优秀的版本控制工具,其具体的的优点和详细介绍,这里就不再多说. 首先来下载和搭建SVN服务器. 现在Subversion已经迁移到apache网站上 ...

  5. 使用nginx部署Yii 2.0\yii-basic-app-2.0.5

    nginx.conf #user nobody;worker_processes 1; #error_log logs/error.log;#error_log logs/error.log noti ...

  6. Symfony2 资料篇

    http://www.chrisyue.com/symfony2-in-action-day-1.html 由于Symfony2现在还没有很完善的中文文档,所以不想看文档的同学可以直接进行点击上面的链 ...

  7. cocos2dx 2.0 CCScrollView的用法以及滑动的原理

    #ifndef __HELLOWORLD_SCENE_H__ #define __HELLOWORLD_SCENE_H__ #include "cocos2d.h" USING_N ...

  8. C++去掉字符串中首尾空格和所有空格

    c++去掉首尾空格是参考一篇文章的,但是忘记文章出处了,就略过吧. 去掉首尾空格的代码如下: void trim(string &s) { if( !s.empty() ) { s.erase ...

  9. skiplist

    §1 Skip List 介绍 Skip List是一种随机化的数据结构,基于并联的链表,其效率可比拟于二叉查找树(对于大多数操作需要O(log n)平均时间).基本上, 跳跃列表是对有序的链表增加上 ...

  10. delphi XE Berlin ReadProcessMemory WriteProcessMemory

    delphi  XE,Berlin [dcc32 Error] Unit9.pas(93): E2033 Types of actual and formal var parameters must ...