You are all excellenttime limit: 1000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 2945 accepted submission (s): 1061
Problem description more than 30 participants in this training team. You are undoubtedly excellent. However, due to the limited number of participating places, you can only select some players to participate in the provincial competition. From the perspective of the school, I always hope to select the best 18 people to form 6 teams to represent the school. However, we also know that it is very difficult to be completely objective. It is difficult to unify the selection criteria.
In order to solve this problem, I have simplified the problem. Now, assuming that each team member is a point in a two-dimensional plane, it is represented by (XI, Yi) coordinates, A player's abilities can be expressed by his Euclidean distance to the origin. This ranking standard is too standard ~ Objectively speaking, it is difficult for new players to have a chance to stand out. Many people are very depressed. In particular, it is not a lot of nonsense. It is not a particularly violent fake **. He is now demanding to reform the ranking rules and has proposed a set of absolutely fair solutions:
Now, we don't use a vertex to represent a player. Instead, we use a vector from the origin point to the node where the player is located to represent a player. If the angle between the vector and the X positive axis is relatively small, it means that the vector has a high capability and the ranking should be top.
This is the famous "pseudo-family rule" (to be honest, I doubt its objectivity because I know that his coordinates are (3.1, 0.1 )...)
The input data contains multiple groups of test instances. The first row of each instance is an integer of n (n <= 100), indicating the number of participants. The next row is the number of 2 * n, coordinates of n players (x1, Y1, X2, y2... XN, yn), N indicates the end of the input data when it is negative.
In particular, all Y coordinates are positive numbers, and all coordinate values are floating point numbers with a decimal number.
For each test instance, output the coordinates after ranking in one row. The coordinates are separated by a space. Specifically, you can assume that the result is unique Based on the pseudo rank rule.
Sample Input
35.0 4.0 3.1 0.1 2.0 2.0-1
Sample output
3.1 0.1 5.0 4.0 2.0 2.0
Authorlcy
Source2007 provincial training team exercise (10) _ Thanks to doomiii
Idea: it is a simple struct. In special cases, the X coordinate is negative. Solution: atan2 function knowledge point: atan2 function, usage method, atan2 (Y, X) included in math. in the header file H, although the parameters in atan2 are the opposite, the obtained arc tangent value is (x, y. The arc tangent value is expressed in radians. The angle value of the arc tangent value is in the positive direction of X, and the angle of the link between the source and the point is expressed in radians. The Code is as follows:
#include<stdio.h>#include<math.h>#include<algorithm>using namespace std;struct node{double x,y,t;}s[10010];int cmp(node a,node b){return a.t<b.t;}int main(){int n,i;while(~scanf("%d",&n),n>=0){for(i=0;i<n;i++){scanf("%lf%lf",&s[i].x,&s[i].y);s[i].t=atan2(s[i].y,s[i].x);} sort(s,s+n,cmp);printf("%.1lf %.1lf",s[0].x,s[0].y);for(i=1;i<n;i++){printf(" %.1lf %.1lf",s[i].x,s[i].y);}printf("\n");}return 0;}
HDU 1785 (You are all excellent) (Math Function atan2 (Y. X) returns the arc tangent value of (x, y)