Points on cycle
Description
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
Output
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.
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
1.500 2.000
563.585 1.251
Sample Output
-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的更多相关文章
- 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
这题的俩种方法都是看别人的代码,方法可以学习学习,要多看看.. 几何题用到向量.. Points on Cycle Time Limit: 1000/1000 MS (Java/Others) ...
- 暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)
Points on Cycle Time Limit:1000MS Memory Limit:32768 ...
- Points on Cycle (hdu1700,几何)
Points on Cycle Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu1700 Points on Cycle
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=1700 题目: Points on Cycle Time Limit: 1000/1000 MS ...
- L - Points on Cycle(旋转公式)
L - Points on Cycle Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- HDU1700:Points on Cycle
Problem Description There is a cycle with its center on the origin. Now give you a point on the cycl ...
- hdu1700 Points on Cycle (数学)
Problem Description There is a cycle with its center on the origin. Now give you a point on the cycl ...
- HDU 1700 Points on Cycle (坐标旋转)
题目链接:HDU 1700 Problem Description There is a cycle with its center on the origin. Now give you a poi ...
随机推荐
- Windows自带的驱动程序例子都在哪里?
MSDN官方说明:https://msdn.microsoft.com/windows/hardware/drivers/samples/index 各个操作系统驱动例子: Windows10 :h ...
- linux命令行与shell脚本编程大全---更多bash shell命令
进程状态:0代表正在运行:S代表在休眠:R代表可运行,正等待运行:Z代表僵化,进程已经结束但父进程已不存在:T代表停止. 查看有那些进程运行:ps -ef 基本的linux文件系统: 1.ext文件 ...
- ios开发 iphone中获取网卡地址和ip地址
这是获取网卡的硬件地址的代码,如果无法编译通过,记得把下面的这几个头文件加上把. #include <sys/socket.h> // Per msqr#include <sys/s ...
- 22. Surrounded Regions
Surrounded Regions Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A ...
- IIS7 rename application or site
rename site 比较容易,在IIS里面就可以直接 rename,也可以用 cmd 的方式 1. 打开 cmd 2. cd C:\Windows\System32\inetsrv 3. appc ...
- 如何在博客中插入jsfiddle的代码
1.进入官网:https://jsfiddle.net/ 可以看到如下界面,顶端的控制按钮包括:保存,运行,代码格式化等: 2.将html.css.js分别写在指定的位置当中,最后一个框result是 ...
- 纸上谈兵:图(graph)
作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 图(graph)是一种比较松散的数据结构.它有一些节点(vertice),在某些节 ...
- C#如何打开DBF数据库文件
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- JS生成雪花
<script type="text/javascript"> (function(){ function snow(left,height,src){ var div ...
- Study Emgu VoteForUniqueness
Recently i was studying Emgu, but find there is a bug in the VoteForUniqueness function in class Fea ...