Problem:
 Score : 600 points    Problem Statement There are N holes in a two-dimensional plane. The coordinates of the i -th hole are (x_i,y_i) .  Let R=10^{10^{10^{10}}} . Ringo performs the following operation:   Randomly choose a point from the interior of a circle of radius R centered at the origin, and put Snuke there. Snuke will move to the hole with the smallest Euclidean distance from the point, and fall into that hole. If there are multiple such holes, the hole with the smallest index will be chosen.   For every i  (1 \leq i \leq N) , find the probability that Snuke falls into the i -th hole.  Here, the operation of randomly choosing a point from the interior of a circle of radius R is defined as follows:   Pick two real numbers x and y independently according to uniform distribution on [-R,R] .  If x^2+y^2\leq R^2 , the point (x,y) is chosen. Otherwise, repeat picking the real numbers x,y until the condition is met.       Constraints  2 \leq N \leq 100  |x_i|,|y_i| \leq 10^6(1\leq i\leq N)  All given points are pairwise distinct.  All input values are integers.         Input Input is given from Standard Input in the following format:  N  x_1  y_1  :  x_N  y_N       Output Print N real numbers. The i -th real number must represent the probability that Snuke falls into the i -th hole.  The output will be judged correct when, for all output values, the absolute or relative error is at most 10^{-5} .        Sample Input 1 2
0 0
1 1      Sample Output 1 0.5
0.5  If Ringo put Snuke in the region x+y\leq 1 , Snuke will fall into the first hole. The probability of this happening is very close to 0.5 .
Otherwise, Snuke will fall into the second hole, the probability of which happening is also very close to 0.5 .       Sample Input 2 5
0 0
2 8
4 5
2 6
3 10      Sample Output 2 0.43160120892732328768
0.03480224363653196956
0.13880483535586193855
0.00000000000000000000
0.39479171208028279727

Solution (Python):
import math

N = int(input())
xys = [tuple(map(int, input().split())) for _ in range(N)]

if N == 2:
    print(0.5)
    print(0.5)
    exit()

outside = [min(range(N), key = lambda i: xys[i])]

go_back_to_while = False
while outside:
    i = outside[-1]
    x1, y1 = xys[i]
    for j in range(N):
        if j in outside:
            continue
        x2, y2 = xys[j]
        sign = 0
        for k, (x3, y3) in enumerate(xys):
            if k == i or k == j:
                continue
            tmp = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)
            if tmp == 0:
                if x1 < x3 < x2 or x1 > x3 > x2 or y1 < y3 < y2 or y1 > y3 > y2:
                    if k in outside:
                        outside.remove(k)
                        outside.append(j)
                        go_back_to_while = True
                        break
                elif x1 < x2 < x3 or x1 > x2 > x3 or y1 < y2 < y3 or y1 > y2 > y3:
                    break
                else:
                    outside.pop() 
                    go_back_to_while = True
                    break
            elif tmp > 0:
                if sign == 0:
                    sign = +1
                elif sign == -1:
                    break
                else:
                    continue
            else:
                if sign == 0:
                    sign = -1
                elif sign == +1:
                    break
                else:
                    continue
        else:
            outside.append(j)
            break
        if go_back_to_while:
            go_back_to_while = False
            break
    else: 
        break 


ans = [0.0] * N

for i in range(-1, len(outside) - 1):
    x1, y1 = xys[outside[i-1]]
    x2, y2 = xys[outside[i]]
    x3, y3 = xys[outside[i+1]]
    v1x, v1y = x2 - x1, y2 - y1
    v2x, v2y = x3 - x2, y3 - y2
    dot = v1x * v2x + v1y * v2y
    len1 = (v1x ** 2 + v1y ** 2)
    len2 = (v2x ** 2 + v2y ** 2)
    ans[outside[i]] = math.acos( max(-1.0, min(1.0, dot / math.sqrt(len1 * len2))) ) / (2 * math.pi)

for a in ans:
    print('{:.20f}'.format(a))

Solution (Python):
import math

def norm(p, q): 
    return (q[1] - p[1], p[0] - q[0])

def magnitude(a):
    return (a[0]**2 + a[1]**2)**.5

def dot(p, q):
    return p[0]*q[0] + p[1]*q[1]

def angle(p, q):
    return math.acos(dot(p, q) / (magnitude(p) * magnitude(q)))

def cross(a, b, c):
    return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0])

def convex_hull(ps):
    ps = sorted(ps)
    qs = []
    n = len(ps)
    for p in ps:
        while len(qs) > 1 and cross(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    t = len(qs)
    for i in range(n - 2, -1, -1):
        p = ps[i]
        while len(qs) > t and cross(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    return qs

n = int(input())
s = [tuple(map(int, input().split())) for _ in range(n)]
ch = convex_hull(s)
ch.pop()
m = len(ch)
d = dict()
for i in range(m):
  u = angle(norm(ch[i-1], ch[i]), norm(ch[i], ch[(i+1)%m]))
  d[ch[i]] = u / 2 / math.pi
for t in s:
  print(0.0 if t not in d else d[t])

Solution (Python):

import numpy as np
from scipy.spatial import ConvexHull
from scipy.spatial.qhull import QhullError
from scipy.spatial.distance import cosine

def solve(n, pts):
    ans = np.zeros(n)

    try:
        
        hull = ConvexHull(pts)
    except QhullError: 
        
        ans[pts.index(min(pts))] = 0.5
        
        ans[pts.index(max(pts))] = 0.5
        return ans

    
    L = hull.vertices.shape[0]

    for i,v in enumerate(hull.vertices):
        
        prv = hull.vertices[(i - 1) % L]
        
        nxt = hull.vertices[(i + 1) % L]

        
        deg = np.arccos(1 - cosine(hull.points[prv] - hull.points[v], hull.points[nxt] - hull.points[v]))

        ans[v] = (np.pi - deg) / (2 * np.pi)

    return ans

def main():
    N = int(input())
    XY = [[int(i) for i in input().split()] for _ in range(N)]
    print(*solve(N, XY), sep="\n")

if __name__ == '__main__':
    main()

Solution (Python):
from math import atan2, pi

N, *XY = map(int, open(0).read().split())
XY = list(zip(*[iter(XY)] * 2))

for i, (x, y) in enumerate(XY):
    D = sorted(atan2(X - x, Y - y) for j, (X, Y) in enumerate(XY) if j != i)
    D.append(D[0] + 2 * pi)

    print(min((b - a - pi for a, b in zip(D, D[1:]) if b - a > pi), default=0) / (2 * pi))

Solution (Python):
from math import atan2, pi

N, *XY = map(int, open(0).read().split())
XY = list(zip(*[iter(XY)] * 2))

for i, (x, y) in enumerate(XY):
    D = sorted(atan2(X - x, Y - y) for j, (X, Y) in enumerate(XY) if j != i)
    D.append(D[0] + 2 * pi)

    ans = 0
    for a, b in zip(D, D[1:]):
        if b - a >= pi:
            ans = (b - a) - pi
            break

    print(ans / (2 * pi))

Solution (Python):
from math import atan2, pi

N, *XY = map(int, open(0).read().split())
XY = list(zip(*[iter(XY)] * 2))

for i, (x, y) in enumerate(XY):
    D = sorted(atan2(X - x, Y - y) for j, (X, Y) in enumerate(XY) if j != i)
    D.append(D[0] + 2 * pi)

    ans = 0
    for a, b in zip(D, D[1:]):
        if b - a >= pi:
            ans = (b - a) - pi

    print(ans / (2 * pi))

Solution (Python):
import numpy as np
from scipy.spatial import ConvexHull
from scipy.spatial.qhull import QhullError
from numpy.linalg import norm


def main():
    N = int(input())
    points = []
    for _ in range(N):
        x, y = map(int, input().split())
        points.append([x, y])

    ans = np.zeros(N)
    try:
        hull = ConvexHull(points)
    except QhullError:
        ans[points.index(min(points))] = ans[points.index(max(points))] = 0.5
        print(*ans, sep='\n')
        return

    v = hull.vertices
    prv_v, nxt_v = np.roll(v, -1), np.roll(v, 1)
    diff_prev = hull.points[prv_v]-hull.points[v]
    diff_next = hull.points[nxt_v]-hull.points[v]
    deg = np.arccos(np.einsum("ij, ij->i", diff_prev, diff_next) /
                    norm(diff_prev, axis=1) / norm(diff_next, axis=1))
    ans[v] = (np.pi - deg) / (2 * np.pi)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import Counter
from math import atan2, pi
readline = sys.stdin.readline
def cross(o, a, b):
    return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])

Prob = Counter()
N = int(readline())
Points = [tuple(map(int, readline().split())) for _ in range(N)]
Pointsorig = Points[:]
Points.sort()

lower = []
for p in Points:
    while len(lower) >= 2 and cross(lower[-2], lower[-1], p) < 0:
        lower.pop()
    lower.append(p)
upper = []
for p in Points[::-1]:
    while len(upper) >= 2 and cross(upper[-2], upper[-1], p) < 0:
        upper.pop()
    upper.append(p)

convexhull = lower[1:-1] + upper
M = len(convexhull)
convexhull += [convexhull[0]]
convexhull += [convexhull[1]]

for i in range(1, M+1):
    pn = convexhull[i]
    A = (convexhull[i-1][1] - pn[1] , convexhull[i-1][0] - pn[0])
    B = (convexhull[i+1][1] - pn[1] , convexhull[i+1][0] - pn[0])
    theta = abs(pi - abs(atan2(*A) - atan2(*B)))
    Prob[pn] = theta/(2*pi)
Ans = [0]*N
for i in range(N):
    Ans[i] = Prob[Pointsorig[i]]
print('\n'.join(map(str, Ans)))

Solution (Python):
import sys
input = sys.stdin.readline
import math

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

Theta = [[0, 0] for _ in range(N)]

line = True
for i in range(N-1):
    x1, y1 = XY[i]
    for j in range(i+1, N):
        x2, y2 = XY[j]
        for k in range(N):
            x3, y3 = XY[k]
            if (y1-y2)*(x1-x3) != (y1-y3)*(x1-x2):
                line = False
                break
    if line:
        break

if line:
    for i, (x1, y1) in enumerate(XY):
        max_x = True
        min_x = True
        max_y = True
        min_y = True
        for j, (x2, y2) in enumerate(XY):
            if i == j: continue
            if x1 <= x2:
                max_x = False
            if x2 <= x1:
                min_x = False
            if y1 <= y2:
                max_y = False
            if y2 <= y1:
                min_y = False
        if max_x or min_x or max_y or min_y:
            Theta[i][1] = math.pi
else:
    for i in range(N-1):
        x1, y1 = XY[i]
        for j in range(i+1, N):
            x2, y2 = XY[j]
            if x1 == x2:
                all_right = True
                all_left = True
                for k in range(N):
                    if k == i or k == j: continue
                    x3, y3 = XY[k]
                    if x3 > x1:
                        all_left = False
                    elif x3 < x1:
                        all_right = False
                if all_right:
                    if y1 > y2:
                        Theta[i][1] = math.pi
                        Theta[j][0] = math.pi
                    elif y1 < y2:
                        Theta[i][0] = math.pi
                        Theta[j][1] = math.pi
            else:
                all_up = True
                all_down = True
                for k in range(N):
                    if k == i or k == j: continue
                    x3, y3 = XY[k]
                    if (y3-y1)*(x1-x2) < (y1-y2)*(x3-x1):
                        if x1-x2 > 0:
                            all_up = False
                        elif x1-x2 < 0:
                            all_down = False
                    elif (y3-y1)*(x1-x2) > (y1-y2)*(x3-x1):
                        if x1-x2 > 0:
                            all_down = False
                        elif x1-x2 < 0:
                            all_up = False
                if all_down:
                    if x1 < x2:
                        theta = math.atan2(x2-x1, y1-y2)
                        Theta[i][0] = theta
                        Theta[j][1] = theta
                    else:
                        theta = math.atan2(x1-x2, y2-y1)
                        Theta[i][1] = theta
                        Theta[j][0] = theta
                if all_up:
                    if x1 < x2:
                        theta = math.atan2(x1-x2, y2-y1)
                        Theta[i][1] = theta
                        Theta[j][0] = theta
                    else:
                        theta = math.atan2(x2-x1, y1-y2)
                        Theta[i][0] = theta
                        Theta[j][1] = theta

for start, end in Theta:
    delta = end - start
    while delta < 0:
        delta += 2*math.pi
    while delta >= 2*math.pi:
        delta -= 2*math.pi
    print(delta/(2*math.pi))

Solution (Python):
import cmath
import math
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7





def det(a: complex, b: complex):
    
    return a.real * b.imag - a.imag * b.real


def graham_scan(points):
    """
    凸包
    :param list of complex|np.ndarray points:
    :rtype: list of complex
    """
    if len(points) <= 2:
        return list(points)
    points = np.sort_complex(points)
    
    sz = 0
    
    ret = [None] * (N * 2)
    for p in points:
        while sz > 1 and det(ret[sz - 1] - ret[sz - 2], p - ret[sz - 1]) <= 0:
            sz -= 1
        ret[sz] = p
        sz += 1
    floor = sz
    for p in reversed(points[:-1]):
        while sz > floor and det(ret[sz - 1] - ret[sz - 2], p - ret[sz - 1]) <= 0:
            sz -= 1
        ret[sz] = p
        sz += 1
    ret = ret[:sz - 1]
    return ret


N = int(sys.stdin.buffer.readline())
X, Y = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))
TAU = math.pi * 2

points = [complex(x, y) for x, y in zip(X, Y)]
pos = {p: i for i, p in enumerate(points)}


points = graham_scan(points)
points = np.array(points, dtype=complex)
assert len(points) >= 2

ans = [0.0] * N

if len(points) == 2:
    ans[pos[points[0]]] = 0.5
    ans[pos[points[1]]] = 0.5
    print(*ans, sep='\n')
    exit()


center = points.mean()
idx = np.angle(points - center).argsort()
points = points[idx]

for i in range(len(points)):
    pr = points[(i + 1) % len(points)]
    p = points[i]
    pl = points[(i - 1) % len(points)]

    
    
    ans[pos[p]] += (math.pi - (cmath.phase(pl - p) - cmath.phase(pr - p)) % TAU) / TAU

print(*ans, sep='\n')

Solution (Python):
from scipy.spatial import ConvexHull as CH
import numpy as np
norm=np.linalg.norm
n,*t=map(int,open(0).read().split())
a=np.reshape(t,(n,2))
try:
	h = CH(a).vertices
except:
	a=a-10**6
	if np.all(a[:,0]==a[0,0]):
		a=np.fliplr(a)
	b=a[:,0]
	M=np.argmax(b)
	m=np.argmin(b)
	for i in range(n):
		print(0.5*(i in (m,M)))
	exit()
l=len(h)
for i in range(n):
	if i in h:
		j=np.where(h==i)[0]
		f,s,t=a[h[j-1]],a[i],a[h[(j+1)%l]]
		print(np.arccos(np.inner(t-s,s-f)/(norm(t-s)*norm(s-f)))[0,0]/(2*np.pi))
	else:
		print(0.)

Solution (Python):
import math
from collections import defaultdict


def norm2(vec):
    return math.sqrt(vec[0]**2 + vec[1]**2)



def ConvexHull(point_list):
    pos2idx = {point_list[i]: i for i in range(len(point_list))}
    y_val = defaultdict(list)
    x_list = sorted(list(set([p[0] for p in point_list])))
    for x, y in point_list:
        y_val[x].append(y)

    upper = [(x_list[0], max(y_val[x_list[0]]))]
    lower = [(x_list[0], min(y_val[x_list[0]]))]
    prev = float('inf')
    for xi in x_list[1:]:
        x0, y0 = upper[-1]
        x1, y1 = xi, max(y_val[xi])
        if (y1 - y0) / (x1 - x0) < prev:
            upper.append((x1, y1))
            prev = (y1 - y0) / (x1 - x0)
        else:
            while True:
                x0, y0 = upper[-1]
                if len(upper) == 1:
                    upper.append((x1, y1))
                    break
                x00, y00 = upper[-2]
                if (y1 - y0) / (x1 - x0) > (y1 - y00) / (x1 - x00):
                    upper.pop()
                else:
                    prev = (y1 - y0) / (x1 - x0)
                    upper.append((x1, y1))
                    break

    prev = -float('inf')
    for xi in x_list[1:]:
        x0, y0 = lower[-1]
        x1, y1 = xi, min(y_val[xi])
        if (y1 - y0) / (x1 - x0) > prev:
            lower.append((x1, y1))
            prev = (y1 - y0) / (x1 - x0)
        else:
            while True:
                x0, y0 = lower[-1]
                if len(lower) == 1:
                    lower.append((x1, y1))
                    break
                x00, y00 = lower[-2]
                if (y1 - y0) / (x1 - x0) < (y1 - y00) / (x1 - x00):
                    lower.pop()
                else:
                    prev = (y1 - y0) / (x1 - x0)
                    lower.append((x1, y1))
                    break

    
    

    upper_idx, lower_idx = [pos2idx[xy] for xy in upper], [pos2idx[xy] for xy in lower]
    if upper_idx[-1] == lower_idx[-1]:
        upper_idx.pop()
    CH_idx = upper_idx
    CH_idx.extend(reversed(lower_idx))
    if CH_idx[0] == CH_idx[-1] and len(CH_idx) > 1:
        CH_idx.pop()
    return CH_idx


N = int(input())
point_list = []
for _ in range(N):
    x, y = map(int, input().split())
    point_list.append((x, y))

CH = ConvexHull(point_list)
if len(CH) == 2:
    ans = [0] * N
    ans[CH[0]] = 0.5
    ans[CH[1]] = 0.5
    for i in range(N):
        print(ans[i])
    exit()
ans = [0] * N
for i in range(len(CH)):
    s, t, u = CH[i-1], CH[i], CH[(i+1)%len(CH)]
    x0, y0 = point_list[s]
    x1, y1 = point_list[t]
    x2, y2 = point_list[u]
    vec0 = (y0-y1, x1-x0)
    vec1 = (y1-y2, x2-x1)
    ans[t] = math.acos((vec0[0] * vec1[0] + vec0[1] * vec1[1]) / (norm2(vec0) * norm2(vec1))) / (2 * math.pi)

for i in range(N):
    print(ans[i])

Solution (Python):
import sys
input = sys.stdin.readline

import numpy as np
from numpy import pi
N = int(input())
X,Y = np.array([input().split() for _ in range(N)],dtype=np.float64).T




def solve(i):
    Xother = np.delete(X,i)
    Yother = np.delete(Y,i)
    angle = np.arctan2(Y[i]-Yother,X[i]-Xother) 
    
    angle -= angle[0]
    
    angle[angle<-pi] += 2*pi
    angle[angle>pi] -= 2*pi
    lower = np.zeros_like(angle)
    upper = np.zeros_like(angle)
    case1 = (angle<=0)
    case2 = (angle>=0)
    lower[case1] = -pi/2
    upper[case1] = angle[case1]+pi/2
    lower[case2] = angle[case2]-pi/2
    upper[case2] = pi/2
    
    return max(0,upper.min() - lower.max())/(2*pi)

answer = [solve(i) for i in range(N)]
print(*answer,sep='\n')

Solution (Python):
import math
pi=3.141592657589793238462643383279


def cross(C, A, B):
    return (C[0] - A[0])*(C[1] - B[1]) - (C[1] - A[1])*(C[0] - B[0])

def convex_hull(P):
    P.sort()
    Q = []
    for p in P:
        while 1 < len(Q) and cross(Q[-2], Q[-1], p) >= 0:
            Q.pop()
        Q.append(p)
    k = len(Q)
    for p in reversed(P[:-1]):
        while k < len(Q) and cross(Q[-2], Q[-1], p) >= 0:
            Q.pop()
        Q.append(p)
    return Q

n=int(input())
arr=[]
for _ in range(n):
  x,y=map(int,input().split())
  arr.append((x,y))
arr2=convex_hull(arr[:])[:-1]
ans=[0]*n
if n==2:
  print(0.5)
  print(0.5)
else:
  for i in range(n):
    pos=arr[i]
    if pos not in arr2:
      continue
    else:
      idx=arr2.index(pos)
      pos1=arr2[idx-1]
      pos2=arr2[(idx+1)%len(arr2)]
      x1=pos[0]-pos1[0]
      y1=pos[1]-pos1[1]
      x2=pos2[0]-pos[0]
      y2=pos2[1]-pos[1]
      angle=abs(math.atan2(x1*y2-x2*y1,x1*x2+y1*y2))
      ans[i]=angle/(2*pi)
  for i in range(n):
    print(ans[i])

Solution (Python):
import math
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
pi=math.pi
hl=[[pi,0,0,-pi] for i in range(n)]
for i in range(n):
    x1,y1=l[i]
    for j in range(i+1,n):
        x2,y2=l[j]
        if x1==x2:
            if y1>y2:
                hl[i][3]=0
                hl[j][0]=0
            else:
                hl[i][0]=0
                hl[j][3]=0
        else:
            r=math.atan((y2-y1)/(x2-x1))+pi/2
            if x2>x1:
                hl[j][3]=max(hl[j][3],r-pi)
                hl[j][0]=min(hl[j][0],r)
                hl[i][1]=max(hl[i][1],r)
                hl[i][2]=min(hl[i][2],r-pi)
            else:
                hl[i][3]=max(hl[i][3],r-pi)
                hl[i][0]=min(hl[i][0],r)
                hl[j][1]=max(hl[j][1],r)
                hl[j][2]=min(hl[j][2],r-pi)
for i in hl:
    a,b,c,d=i
    print((max(0,a-b)+max(0,c-d))/(2*pi))

Solution (Python):
import math
from functools import reduce
n = int(input())
xy = []
for i in range(n):
    x, y = [int(item) for item in input().split()]
    xy.append([x, y, i])

def convex_hull_graham(points):
    TURN_LEFT, TURN_RIGHT, TURN_NONE = (1, -1, 0)

    def cmp(a, b):
        return (a > b) - (a < b)

    def turn(p, q, r):
        return cmp((q[0] - p[0])*(r[1] - p[1]) - (r[0] - p[0])*(q[1] - p[1]), 0)

    def _keep_left(hull, r):
        while len(hull) > 1 and turn(hull[-2], hull[-1], r) == TURN_RIGHT:
            hull.pop()
        if not len(hull) or hull[-1] != r:
            hull.append(r)
        return hull

    points = sorted(points)
    l = reduce(_keep_left, points, [])
    u = reduce(_keep_left, reversed(points), [])
    return l.extend(u[i] for i in range(1, len(u) - 1)) or l

ret = convex_hull_graham(xy)
ret.append(ret[0])
ret.append(ret[1])
thetas = [0.0] * n
for i in range(1, len(ret)-1):
    v1 = [-ret[i][1] + ret[i-1][1], ret[i][0] - ret[i-1][0]]
    v2 = [-ret[i+1][1] + ret[i][1], ret[i+1][0] - ret[i][0]]
    v1_norm = math.sqrt(v1[0]**2.0 + v1[1]**2.0)
    v2_norm = math.sqrt(v2[0]**2.0 + v2[1]**2.0)
    thetas[ret[i][2]] = math.acos((v1[0]*v2[0] + v1[1]*v2[1]) / (v1_norm * v2_norm))
for item in thetas:
    print(item / (math.pi * 2.0))

Solution (Python):
import numpy as np
from scipy.spatial import ConvexHull
from scipy.spatial.qhull import QhullError
from scipy.spatial.distance import cosine

def main(points):
    ans = [0.0] * N

    try:
        hull = ConvexHull(np.asarray(points))
    except QhullError:
        ans[points.index(min(points))] = ans[points.index(max(points))] = 0.5
        return ans

    L = hull.vertices.shape[0]

    for i, v in enumerate(hull.vertices):
        prv, nxt = hull.vertices[[(i+L-1) % L, (i+1) % L]]
        deg = np.arccos(1-cosine(hull.points[prv]-hull.points[v],
                                 hull.points[nxt]-hull.points[v]))
        ans[v] = (np.pi-deg)/(2*np.pi)
    return ans


if __name__ == '__main__':
    N = int(input())
    points = []
    for _ in range(N):
        x, y = map(int, input().split())
        points.append([x, y])
    print(*main(points), sep='\n')

Solution (Python):
import sys
input=sys.stdin.readline
from math import atan2,pi

def InnerProduct(V0,V1):
    x0,y0=V0
    x1,y1=V1
    return x0*x1+y0*y1
def CrossProduct(V0,V1):
    x0,y0=V0
    x1,y1=V1
    return x0*y1-x1*y0
def clockwise(P0,P1,P2):
    V0,V1=(P1[0]-P0[0],P1[1]-P0[1]),(P2[0]-P0[0],P2[1]-P0[1])
    return CrossProduct(V0,V1)<0

def MonotoneChain(V):
    upper,lower=[],[]
    P=sorted(V)
    for p in P:
        while len(lower)>1 and (not clockwise(lower[-2],lower[-1],p)):
            lower.pop()
        lower.append(p)
    for p in P[::-1]:
        while len(upper)>1 and (not clockwise(upper[-2],upper[-1],p)):
            upper.pop()
        upper.append(p)
    return lower[:-1]+upper[:-1]

n=int(input())
P=[tuple(map(int,input().split())) for _ in range(n)]
d={p: i for i,p in enumerate(P)}
ans=[0]*n
CH=MonotoneChain(P)
CH+=[CH[0],CH[1]]
for (x0,y0),(x1,y1),(x2,y2) in zip(CH,CH[1:],CH[2:]):
    V0,V1=(x0-x1,y0-y1),(x2-x1,y2-y1)
    ans[d[(x1,y1)]]=(pi-atan2(CrossProduct(V0,V1),InnerProduct(V0,V1)))/(2*pi)
for a in ans:
    print(a)

Solution (Python):
import math

n = int(input())
ps = [tuple(map(int, input().split())) for _ in range(n)]
mp = {tuple(p): i for i, p in enumerate(ps)}


def ccw(p0, p1, p2):
    return (p1[0] - p0[0]) * (p2[1] - p0[1]) - (p1[1] - p0[1]) * (p2[0] - p0[0]) >= 0   


def convex_hull(ps):
    upper = []
    lower = []
    ps.sort()
    for p in ps:
        while len(lower) > 1 and ccw(lower[-2], lower[-1], p):
            lower.pop()
        lower.append(p)

    for p in ps[::-1]:
        while len(upper) > 1 and ccw(upper[-2], upper[-1], p):
            upper.pop()
        upper.append(p)
    return lower[:-1] + upper[:-1]

ans = [0] * n
ch = convex_hull(ps)
ch += [ch[0]]
ch += [ch[1]]

for pre, now, next in zip(ch, ch[1:], ch[2:]):
    x0 = now[0] - pre[0]
    y0 = now[1] - pre[1]
    x1 = next[0] - now[0]
    y1 = next[1] - now[1]
    ans[mp[tuple(now)]] = math.atan2(x1*y0 - x0*y1, x0*x1 + y0*y1) / (2 * math.pi)  

for a in ans:
    print(a)

Solution (Python):
import math

n = int(input())
c = [[0]*2 for i in range(n) ]
a = [0] * n
p = math.pi
for i in range(n):
    c[i][0], c[i][1] = map(float, input().split())

def f(ax, ay, bx, by, cx, cy):
    vx = ax - cx
    vy = ay - cy
    wx = bx - cx
    wy = by - cy
    s = 1
    if vx * wy - vy * wx < 0: s = -1
    p = vx * wx + vy * wy
    q = ( vx * vx + vy * vy ) ** 0.5
    r = ( wx * wx + wy * wy ) ** 0.5
    t = p / (q * r)
    t = max(-1, min(1, t))
    t = (math.acos( t )) * s
    return t

for i in range(n):
    k = (i+1)%n
    tax = 0
    tin = 0
    for j in range(n):
        if j != i and j != k:
            t = f(c[k][0], c[k][1], c[j][0], c[j][1], c[i][0], c[i][1])
            tax = max(tax, t)
            tin = min(tin, t)
    if tax - tin < p:
        a[i] = (p - tax + tin) / (p * 2)

for i in range(n):
    print(round(a[i], 6))

Solution (Python):
from math import pi, atan2

def andrange(a, b):
    if a == (0, 0) or b == (0, 0): return (0, 0)
    if a == (0, 1): return b
    if b == (0, 1): return a
    if a[0] > b[0]: a, b = b, a
    if b[1] < a[1]: return b
    if b[0] < a[1]: return (b[0], a[1])
    if b[1] < a[0] + 1: return (0, 0)
    if b[1] < a[1] + 1: return (a[0], b[1] - 1)
    return a

def calcrange(P, Q):
    c = atan2(P[1]-Q[1], P[0]-Q[0]) / (2*pi)
    if c > 0: return (c, c+0.5)
    else: return (c+1, c+1.5)

N = int(input())
X = []
for _ in range(N):
    x, y = map(int, input().split())
    X.append((x, y))

A = [(0, 1) for _ in range(N)]

for i in range(N):
    for j in range(N):
        if i != j:
            A[i] = andrange(A[i], calcrange(X[i], X[j]))

for a in A:
    print("{:.15f}".format(a[1] - a[0]))

Solution (Python):
from math import pi, atan2

def andrange(a, b):
    if a == (0, 0) or b == (0, 0): return (0, 0)
    if a == (0, 1): return b
    if b == (0, 1): return a
    if a[0] > b[0]: a, b = b, a
    if b[1] < a[1]: return b
    if b[0] < a[1]: return (b[0], a[1])
    if b[1] < a[0] + 1: return (0, 0)
    if b[1] < a[1] + 1: return (a[0], b[1] - 1)
    return a

def calcrange(P, Q):
    c = atan2(P[1]-Q[1], P[0]-Q[0]) / (2*pi)
    if c > 0: return (c, c+0.5)
    else: return (c+1, c+1.5)

N = int(input())
X = []
for _ in range(N):
    x, y = map(int, input().split())
    X.append((x, y))

A = [(0, 1) for _ in range(N)]

for i in range(N):
    for j in range(N):
        if i != j:
            A[i] = andrange(A[i], calcrange(X[i], X[j]))

for a in A:
    print("{:.15f}".format(a[1] - a[0]))

Solution (Python):
import math
pi = math.atan(1)*4

def andrange(a, b):
    if a == (0, 0) or b == (0, 0): return (0, 0)
    if a == (0, 1): return b
    if b == (0, 1): return a
    if a[0] > b[0]: a, b = b, a
    if b[1] < a[1]:
        return b
    if b[0] < a[1] and b[1] >= a[1]:
        return (b[0], a[1])
    if b[0] >= a[1] and b[1] < a[0] + 1:
        return (0, 0)
    if b[1] >= a[0] + 1 and b[1] < a[1] + 1:
        return (a[0], b[1] - 1)
    if b[1] >= a[0] + 1 and b[1] >= a[1] + 1:
        return a

def calcrange(P, Q):
    c = calc(P, Q)
    if c > 0:
        return (c, c+0.5)
    else:
        return (c+1, c+1.5)

def calc(P, Q):
    x = P[0] - Q[0]
    y = P[1] - Q[1]
    if x == 0:
        return 0.25 if y > 0 else -0.25
    t = math.atan(y/x)
    return t/(2*pi) if x > 0 else (t/(2*pi) % 1) - 0.5

N = int(input())
X = []
for _ in range(N):
    x, y = map(int, input().split())
    X.append((x, y))

A = [(0, 1) for _ in range(N)]

for i in range(N):
    for j in range(N):
        if i != j:
            A[i] = andrange(A[i], calcrange(X[i], X[j]))

for a in A:
    print("{:.20f}".format(a[1] - a[0]))

Solution (Python):
import math;q=2*math.pi
from cmath import phase as h
t=lambda x:h(x)+(q if 0>h(x)else 0)
n=int(input())
r=range(n)
c=[complex(input().replace(' -', '-').replace(' ','+')+"j")for _ in r]
for i in r:a=sorted([t(c[j]-c[i])/q for j in r if j!=i]);d=[a[j]-a[j-1] for j in r[:-1]];d[0]+=1;print(max(max(d)-1/2,0))

Solution (Python):
from math import pi,atan2
q = 2*pi
def deg(a,b):
    d = b-a
    t = atan2(d.real, d.imag)
    if t<0: t += q
    return t
n = int(input())
cs = []
for _ in range(n):
    a,b = map(int,input().split())
    cs += [complex(a,b)]
for i in range(n):
    args = [deg(cs[i],cs[j])/q for j in range(n) if j!=i]
    args = sorted(args)
    dif = [args[i]-args[i-1] for i in range(n-1)]
    dif[0] += 1
    print(max(max(dif) - 1/2, 0))

Solution (Python):
from math import atan2,pi
N=int(input())
points=[[int(i) for i in input().split()] for i in range(N)]
p=[0]*N

for i in range(N):
  angle_p=[]
  angle_n=[]
  for j in range(N):
    if i!=j:
      c=atan2(points[i][1]-points[j][1],points[i][0]-points[j][0])
      if c>=0:
        angle_p.append(c)
      else:
        angle_n.append(c)
 
  if len(angle_n)==0:
    d=max(angle_p)-min(angle_p)
  elif len(angle_p)==0:
    d=max(angle_n)-min(angle_n)
  elif max(angle_p)-min(angle_n)<pi:
    d=max(angle_p)-min(angle_n)
  elif pi-min(angle_p)+max(angle_n)<0:
    d=2*pi-min(angle_p)+max(angle_n)
  else:
    d=pi
  p[i]=(pi-d)/(2*pi)
    
for i in range(N):
  print(p[i])

Solution (Python):





"""
AGC021 B
"""

import math
from collections import defaultdict

n = int(input())
ps = [tuple(map(int, input().split())) for i in range(n)]


def dist(rad, p):
    radtmp = 2*math.pi*rad/maxcut
    return -p[0]*math.cos(radtmp)-p[1]*math.sin(radtmp)


def closest(rad):
    tmp = dist(rad, ps[0])
    itmp = 0
    for i, pp in enumerate(ps):
        tmp2 = dist(rad, pp)
        if tmp2 < tmp:
            itmp = i
            tmp = tmp2
    return itmp


maxcut = 2**20


binary = defaultdict(int)
binary[0] = closest(0)
binary[maxcut] = binary[0]
binary[maxcut//2] = closest(maxcut//2)
binary[maxcut//4] = closest(maxcut//4)
binary[3*maxcut//4] = closest(3*maxcut//4)


def fillbinary(ll, rr):
    if binary[ll] != binary[rr] and rr-ll != 1:
        mm = (ll+rr)//2
        binary[mm] = closest(mm)
        fillbinary(ll, mm)
        fillbinary(mm, rr)


fillbinary(0, maxcut//4)
fillbinary(maxcut//4, maxcut//2)
fillbinary(maxcut//2, 3*maxcut//4)
fillbinary(3*maxcut//4, maxcut)


binkeys = sorted(binary.keys())
ansli = [0]*n
beforekey = 0
for i in binkeys:
    ansli[binary[i]] += i-beforekey
    beforekey = i


for i in range(n):
    print(ansli[i]/maxcut)

Solution (Python):
import math
import sys
def cross(a, b):
	return a[0]*b[1]-a[1]*b[0]
def dot(a, b):
	return a[0]*b[0]+a[1]*b[1]
def counterclockwise(a, b):
	return cross(a, b)<0
def sub(a, b):
	return [a[0]-b[0], a[1]-b[1]]
n=input()
p=[map(int, raw_input().split()) for i in range(n)]
index={tuple(p[i]): i for i in range(n)}
p.sort()
hull=[p[0]]
min_size=1
for i in range(1, n):
	while len(hull)>min_size and not counterclockwise(sub(p[i], hull[-1]), sub(hull[-1], hull[-2])):
		del hull[-1]
	hull.append(p[i])
assert hull[-1]==p[-1]
min_size=len(hull)
for i in range(n-2, -1, -1):
	while len(hull)>min_size and not counterclockwise(sub(p[i], hull[-1]), sub(hull[-1], hull[-2])):
		del hull[-1]
	hull.append(p[i])
assert hull[0]==hull[-1]==p[0]
del hull[-1]
result=[0.0]*n
print>>sys.stderr, hull
for i in range(len(hull)):
	a=sub(hull[(i+1)%len(hull)], hull[i])
	b=sub(hull[i], hull[i-1])
	value=dot(a, b)/math.sqrt(dot(a, a))/math.sqrt(dot(b, b))
	value=min(max(value, -1.0), 1.0)
	angle=math.acos(value)
	result[index[tuple(hull[i])]]=angle
for i in range(n):
	print result[i]/math.pi/2, 
print