F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Closed Paths

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 392    Accepted Submission(s): 136


Problem Description
JFantasy has fallen in love with a beautiful girl (An ICPC volunteer?). Every afternoon, when the sun set, the girl comes out from her dorm, walks around the campus, and returns to her dorm. The girl¡¯s walking path can be considered as a closed polyline. A closed polyline is a curve specified by a sequence of points (P1, P2, ¡­, Pn) so that the curve consists of the line segments P1P2, P2P3, ¡­, Pn-1Pn, PnP1. Note that two line segments may intersect, coincide or partially coincide with each other. The points P1, P2, ¡­, Pn are also called vertices of the polyline. While the girl is walking along the path, JFantasy is standing at some point which is not lying on the path. During the girl¡¯s walking, the spoony boy rotates himself such that he can always see the girl directly in front of him. The boy may sometimes rotate counter-clockwise, and sometimes rotate clockwise. If the boy stands at point P, let AP denote the total degrees the boy rotate counter-clockwise, and BP denote the total degrees the boy rotate clockwise. It is not difficult to see that AP ¨C BP is a multiple of 360, because when the girl finishes walking, the boy faces in the same direction as when the girl starts walking. We define the rotation number of P to be (AP ¨C BP) / 360.

LCQ is one of JFantasy¡¯s G (G for good) friends. He has found JFantasy¡¯s secret, and got an idea of making fun of him. He wants to put JFantasy at some point of which the rotation number is maximum given the walking path of the girl. To simplify the problem, we assume that the point where JFantasy can be put must be on a straight line. Formally, the problem can be stated as follows: Given the coordinates of (P1, P2, ¡­, Pn), which specifies the girl¡¯s walking path, you are asked to find the largest possible rotation number among all the points that are on the X axis, but not on the girl¡¯s walking path.
 

Input
The input begins with a line containing an integer T (T<=100), which indicates the number of test cases. Each case begins with a line containing an integer N (2<=N<=1000), indicating the number of vertices of the girl¡¯s walking path. The following N lines each contain two integers xi and yi (-1000<= xi, yi <=1000), indicating the coordinates of the ith vertex Pi.
 

Output
For each case, output the largest possible rotation number in a line.
 

Sample Input
3 2 1 2 2 1 6 1 -1 2 -1 2 1 3 1 3 0 1 0 5 1 1 -1 0 1 -1 0 1 0 -1
 

Sample Output
0 0 2
 

Author
SYSU
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-05 13:33:57, Gzip enabled