HDU 1700 复数应用
2015-10-10 18:49
253 查看
Points on Cycle
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2074 Accepted Submission(s): 761
[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
There are T test cases, in each case there are 2 decimal number representing the coordinate of the given point.
[align=left]Output[/align]
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.
[align=left]Sample Input[/align]
2
1.500 2.000
563.585 1.251
[align=left]Sample Output[/align]
0.982 -2.299 -2.482 0.299
-280.709 -488.704 -282.876 487.453
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n=0;
scanf("%d",&n);
while(n--)
{
double a=0.0,b=0.0;
double x1,y1,x2,y2;
scanf("%lf%lf",&a,&b);
x1=-0.5*a-0.5*sqrt(3)*b;
y1=0.5*sqrt(3)*a-b*0.5;
x2=-0.5*a+0.5*sqrt(3)*b;
y2=-0.5*sqrt(3)*a-b*0.5;
if(y1 < y2)
{
printf("%.3lf %.3lf %.3lf %.3lf\n", x1, y1, x2, y2);
}
else if(fabs(y1 - y2) < 0.0005)
{
if(x1 < x2)
{
printf("%.3lf %.3lf %.3lf %.3lf\n", x1, y1, x2, y2);
}
else
{
printf("%.3lf %.3lf %.3lf %.3lf\n", x2, y2, x1, y1);
}
}
else
{
printf("%.3lf %.3lf %.3lf %.3lf\n", x2, y2, x1, y1);
}
}
return 0;
}
相关文章推荐
- 【解决】kettle启动时出现的Java Runtime Environment异常
- 1.JS设计模式-this,call&apply
- Swift开放StatsD后上传数据的出现,出现退换货503的Bug
- Nginx出现413 Request Entity Too Large错误解决方法
- jquery的使用
- 一道数列的规律题(使用递归解决)
- git与IDE开发[git for windows & TortoiseGit]
- ural 2046 The First Day at School
- MyEclipse创建HelloWeb
- CVPR 2015 Oral概览 - 第一天上午
- GTK+浅谈之十五GObject面向对象的继承
- 例10-6 uva1635(唯一分解定理)
- VMware vSphere与vCenter许可及价格分析
- 例10-6 uva1635(唯一分解定理)
- Vagaa, eMule and Apple
- codeforces 584C Marina and Vasya
- 云计算(6)--一些MapReduce的例子
- ScrollView嵌套ListView问题
- 5555
- Android Custom View NullPointerException