您的位置:首页 > 其它

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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: