/* The idea is completely messy, so you can write it if you don't have a clear idea at the beginning. I'm dizzy, various wa.
Ideas:
Find the leftmost vertex d in the bottom of all vertices. Then find the link between D and each other and the X-axis
Angle Between (0 <= π because the Y coordinate of D is the smallest ). Then sort from small to large to find the storage array
Point n/2 is another point. */
My code:
# Include <iostream>
# Include <cstdio>
# Include <cstring>
# Include <algorithm>
# Include <cmath>
# Define PI 3.1415926535
Using namespace STD;
Const int n= 10010;
Struct point {
Double X;
Double Y;
} P [N];
Struct angle {
Double Ang;
Int I;
} A [n];
Point TMP;
Bool CMP (angle A, angle B ){
Return A. Ang <B. Ang;
}
Int main (){
// Freopen ("data. In", "r", stdin );
Int N, I, D, J;
Double B, C;
Scanf ("% d", & N );
Scanf ("% lf", & P [1]. X, & P [1]. y );
B = P [1]. X; C = P [1]. Y; D = 1;
For (I = 2; I <= N; I ++ ){
Scanf ("% lf", & P [I]. X, & P [I]. y );
If (C> P [I]. Y ){
B = P [I]. X; C = P [I]. Y; D = I;
}
If (C = P [I]. Y & B> P [I]. X ){
B = P [I]. X; C = P [I]. Y; D = I;
}
}
For (j = 1, I = 1; I <= N; I ++ ){
If (I! = D ){
A [J]. I = I;
B = P [I]. X-P [D]. X;
C = P [I]. Y-P [D]. Y;
If (B = 0) {A [J ++]. Ang = PI/2; continue ;}
If (C = 0) {A [J ++]. Ang = 0; continue ;}
If (P [I]. x <p [D]. X)
A [J ++]. Ang = pi-atan (C/B );
Else
A [J ++]. Ang = atan (C/B );
}
}
Sort (a + 1, A + N, CMP );
/* For (I = 1; I <n; I ++ ){
Printf ("% lf % d \ n", a [I]. Ang, a [I]. I );
}*/
Printf ("% d \ n", D, a [n/2]. I );
Return 0;
}