You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: the length of the side that is parallel to the Ox axis, equals w, the length of the side that is parallel to the Oy axis, equals h. The second rectangle can be obtained by rotating the first rectangle relative to the origin of coordinates by angle α. [Image] 

Your task is to find the area of the region which belongs to both given rectangles. This region is shaded in the picture.


-----Input-----

The first line contains three integers w, h, α (1 ≤ w, h ≤ 10^6; 0 ≤ α ≤ 180). Angle α is given in degrees.


-----Output-----

In a single line print a real number — the area of the region which belongs to both given rectangles.

The answer will be considered correct if its relative or absolute error doesn't exceed 10^{ - 6}.


-----Examples-----
Input
1 1 45

Output
0.828427125

Input
6 4 30

Output
19.668384925



-----Note-----

The second sample has been drawn on the picture above.

Difficulty: competition

Starter code:

Solutions:
from math import sin, cos, tan, atan, pi


def main():
    w, h, a = map(int, input().split())
    a = min(a, 180 - a) * pi / 180
    if h > w:
        h, w = w, h
    if h * (1 + cos(a)) < w * sin(a):
        res = h * h / sin(a)
    else:
        res = h * w - ((w - h * tan(a / 2)) ** 2 * tan(a) + (h - w * tan(a / 2)) ** 2 * tan(a)) / 4
    print('{:.9f}'.format(res))


def __starting_point():
    main()
__starting_point()

from math import radians, cos, sin, atan2

def rotate(point, alpha):
    x = point[0]
    y = point[1]
    return (x * cos(alpha) - y * sin(alpha), x * sin(alpha) + y * cos(alpha))

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

def m(end, start):
    return (end[0] - start[0], end[1] - start[1])

def area(poly):
    ret = 0
    n = len(poly)

    for i in range(n):
        j = (i + 1) % n
        ret += crs(poly[i], poly[j])

    return abs(ret) / 2.0

def intersect(a, b, c, d):
    r = crs(m(c, d), m(a, d)) * crs(m(c, d), m(b, d)) <= 0
    r &= crs(m(b, a), m(c, a)) * crs(m(b, a), m(d, a)) <= 0
    if not r:
        return None

    x1 = a[0]
    y1 = a[1]

    x2 = c[0]
    y2 = c[1]

    dx1 = b[0] - a[0]
    dx2 = d[0] - c[0]

    dy1 = b[1] - a[1]
    dy2 = d[1] - c[1]

    if dx2 * dy1 == dx1 * dy2:
        return None

    t = ((x1 - x2) * dy2 + (y2 - y1) * dx2) / (dx2 * dy1 - dx1 * dy2)
    return (x1 + t * dx1, y1 + t * dy1)


w, h, alpha = list(map(int, input().split()))

if alpha == 0 or alpha == 180:
    print(w * h)
else:
    alpha = radians(alpha) 
    pnt = []

    pnt.append((w / 2, h / 2))
    pnt.append((-w / 2, h / 2))
    pnt.append((-w / 2, -h / 2))
    pnt.append((w / 2, -h / 2))


    pnt2 = []
    for p in pnt:
        pnt2.append(rotate(p, alpha))

    pnt2.append(pnt2[0])
    pnt.append(pnt[0])

    points_total = []

    for st in range(4):
        for en in range(4):
            t = intersect(pnt[st], pnt[st + 1], pnt2[en], pnt2[en + 1])

            if t != None:
                points_total.append(t)

    points_total = sorted(points_total, key=lambda x: atan2(x[1], x[0]))

    print(area(points_total))


from math import sin,cos,tan
PI = 3.141592653589793238463
[w,h,a] =[int(i) for i in input().split()]
if h > w:
    h,w = w,h
if a > 90:
    a = 180 - a
if a==0:
    print(w*h)
else:
    b = (a*PI)/180
    w = w/2.0
    h = h/2.0
    if tan(b/2) >= h/w:
        print(4*h*h/sin(b))
    else:
        ans = 4*w*h
        m = -1 / tan(b)
        c = w*sin(b) + w*cos(b) / tan(b)
        ans = ans - (h - m*w - c)*(w - (h - c)/m)
        m = tan(b)
        c = h*cos(b) + h*sin(b)*tan(b)
        ans = ans - (h + m*w - c)*((h - c)/m + w)
        print (ans)


from math import sin,cos,tan,pi
[w,h,a] =[int(i) for i in input().split()]
if h > w:
    h,w = w,h
if a > 90:
    a = 180 - a
if a==0:
    print(w*h)
else:
    b = (a*pi)/180
    w = w/2.0
    h = h/2.0
    if tan(b/2) >= h/w:
        print(4*h*h/sin(b))
    else:
        ans = 4*w*h
        m = -1 / tan(b)
        c = w*sin(b) + w*cos(b) / tan(b)
        ans = ans - (h - m*w - c)*(w - (h - c)/m)
        m = tan(b)
        c = h*cos(b) + h*sin(b)*tan(b)
        ans = ans - (h + m*w - c)*((h - c)/m + w)
        print (ans)


from math import sin, cos, tan, atan, pi


def main():
    w, h, a = map(int, input().split())
    a = min(a, 180 - a) * pi / 180
    if h > w:
        h, w = w, h
    if h * (1 + cos(a)) < w * sin(a):
        res = h * h / sin(a)
    else:
        res = h * w - ((w - h * tan(a / 2)) ** 2 * tan(a) + (h - w * tan(a / 2)) ** 2 * tan(a)) / 4
    print('{:.9f}'.format(res))


def __starting_point():
    main()
__starting_point()

from math import *

w,h,alpha = [int(x) for x in input().strip().split()]

if alpha > 90 : alpha = 180 - alpha
if w < h: w,h = h,w

c = cos(alpha * pi / 180.0)
s = sin(alpha * pi / 180.0)
t = tan(alpha * pi / 360.0)

print(h * h / s) if t > h / w else print( (w * h - (w * w + h * h) / 2 * tan(alpha * pi / 360.0)) / (c))

import math
w,h,alpha=list(map(lambda x: int(x),input().split(" ")));

if alpha>90: alpha=180-alpha;
if alpha==0 : print(w*h);
elif alpha==90:
  print(min(w,h)**2);


else:
  limit=2*(math.degrees(math.atan(h/w)));
  if limit>90: limit=180-limit;
  c=math.cos(math.radians(alpha));
  s=math.sin(math.radians(alpha));
 # print(limit);
  if alpha>=limit:
    print(min(w,h)**2/s);
  else:
    print(w*h -((c-1)*((4*w*h*s)-2*(w**2+h**2))/(4*s*c)));

import math

w, h, a = list(map(int, input().strip().split()))

if h > w:
    w, h = h, w

if a > 90:
    a = 90 - (a - 90)

a = math.radians(a)

if a < 2 * math.atan2(h, w):
    area = w * h

    s = (w / 2) - (h / 2 * math.tan(a / 2))
    bigger_area = 0.5 * s * s * math.tan(a)

    s = (h / 2) - (w / 2 * math.tan(a / 2))
    lower_area = 0.5 * s * s * math.tan(a)

    print(area - 2 * bigger_area - 2 * lower_area)
else:
    print(h * h / math.sin(a))



import math

w, h, a = list(map(int, input().strip().split()))

if h >   w:
    w, h = h, w

if a > 90:
    a = 90 - (a - 90)

a = math.radians(a)

if a < 2 * math.atan2(h, w):
    area = w * h

    s = (w / 2) - (h / 2 * math.tan(a / 2))
    bigger_area = 0.5 * s * s * math.tan(a)

    s = (h / 2) - (w / 2 * math.tan(a / 2))
    lower_area = 0.5 * s * s * math.tan(a)

    print(area - 2 * bigger_area - 2 * lower_area)
else:
    print(h * h / math.sin(a))



import math
from decimal import *
getcontext().prec = 40

EPS = Decimal(0.000000000000000000001)
PI = Decimal(3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328)

def labs(x):
	if x < 0:
		return -x
	return x

class Point:
	def __init__(self, x, y):
		self.x = x
		self.y = y
	
	def Add(self, p):
		self.x += p.x
		self.y += p.y
	
	def Sub(self, p):
		self.x -= p.x
		self.y -= p.y

	def Scale(self, v):
		self.x *= v
		self.y *= v

	def Rotate(self, angle):
		newX = self.x * Decimal(math.cos(angle)) - self.y * Decimal(math.sin(angle))
		newY = self.x * Decimal(math.sin(angle)) + self.y * Decimal(math.cos(angle))
		self.x = newX
		self.y = newY
	
	def Equals(self, p):
		if Decimal(labs(p.x - self.x)) < EPS and Decimal(labs(p.y - self.y)) < EPS:
			return True
		return False

class Line:
	def __init__(self, start, end):
		self.start = start
		self.end = end
	
	def GetIntersection(self, l):
		a = Point(self.start.x, self.start.y)
		b = Point(self.end.x, self.end.y)
		c = Point(l.start.x, l.start.y)
		d = Point(l.end.x, l.end.y)
		ab = Point(self.end.x, self.end.y)
		cd = Point(l.end.x, l.end.y)
		ab.Sub(a)
		cd.Sub(c)
		k = Decimal((cd.x * (a.y - c.y) + cd.y * (c.x - a.x)) / (ab.x * cd.y - ab.y * cd.x))
		ab.Scale(k)
		a.Add(ab)
		return a

class Polygon:
	def __init__(self, vertices):
		self.vertices = vertices

	def GetArea(self): 
		area = Decimal(0)
		for i in range(0, len(self.vertices)):
			area += self.vertices[i].x * self.vertices[(i + 1) % len(self.vertices)].y - self.vertices[(i + 1) % len(self.vertices)].x * self.vertices[i].y
		return Decimal(labs(area)) / Decimal(2)

x, y, alpha = input().split()
x = Decimal(x)
y = Decimal(y)
if x < y:
	tmp = x
	x = y
	y = tmp
alpha = Decimal(alpha)
singleArea = x * y
if alpha > 90:
	alpha = Decimal(180) - alpha
if alpha == 0:
	print(singleArea)
	return
alpha = alpha * PI / Decimal(180)
a = Point(x / Decimal(2), y / Decimal(2))
b = Point(x / Decimal(2), -y / Decimal(2))
c = Point(-x / Decimal(2), -y / Decimal(2))
d = Point(-x / Decimal(2), y / Decimal(2))
e = Point(a.x, a.y)
f = Point(b.x, b.y)
g = Point(c.x, c.y)
h = Point(d.x, d.y)
e.Rotate(alpha)
f.Rotate(alpha)
g.Rotate(alpha)
h.Rotate(alpha)
ab = Line(a, b)
bc = Line(b, c)
cd = Line(c, d)
da = Line(d, a)
ef = Line(e, f)
fg = Line(f, g)
gh = Line(g, h)
he = Line(h, e)
area = 0
if a.Equals(f):
	t1 = Polygon([he.GetIntersection(da), e, f])
	t2 = Polygon([fg.GetIntersection(bc), g, h])
	area = singleArea - t1.GetArea() - t2.GetArea()
elif f.y > a.y:
	p1 = Polygon([he.GetIntersection(da), e, f, fg.GetIntersection(da)])
	p2 = Polygon([fg.GetIntersection(bc), g, h, he.GetIntersection(bc)])
	area = singleArea - p1.GetArea() - p2.GetArea()
else:
	t1 = Polygon([da.GetIntersection(he), e, ef.GetIntersection(da)])
	t2 = Polygon([ef.GetIntersection(ab), f, fg.GetIntersection(ab)])
	t3 = Polygon([fg.GetIntersection(bc), g, gh.GetIntersection(bc)])
	t4 = Polygon([gh.GetIntersection(cd), h, he.GetIntersection(cd)])
	area = singleArea - t1.GetArea() - t2.GetArea() - t3.GetArea() - t4.GetArea()
print(area)


from math import *
w,h,alpha = [int(x) for x in input().strip().split()]
if alpha > 90 : alpha = 180-alpha
if w < h: w,h = h,w
c = cos(alpha*pi/180.0)
s = sin(alpha*pi/180.0)
t = tan(alpha*pi/360.0)
 
print(h*h/s) if t > h/w else print( (w*h-(w*w+h*h)/2*tan(alpha*pi/360.0))/(c) )
 	   	 	  	 		 			 	 				   	

from math import *
from sys import stdin, stdout 

io = stdin.readline().split()

w = float(io[0])
h = float(io[1])
a = float(io[2])

if (a > 90): a = 180 - a

if (a == 0) :
    print(w * h)
elif (a == 90) :
    print(min(w, h) ** 2)
else :
    a = a * pi / 180.0
    if (w < h) : w, h = h, w
    corner_x = cos(a) * (w / 2.0) + sin(a) * (h / 2.0)
    if (corner_x >= w / 2 ) :
        x0 = w / 2.0 + (h / 2.0 - (h / 2.0) / cos(a)) * (cos(a) / sin(a))
        y0 = h / 2.0 - (tan(a) * (- w / 2.0) + (h / 2.0) / cos(a))
        x1 = w / 2.0 - (h / 2.0 - (w / 2.0) / sin(a)) * (-tan(a))
        y1 = h / 2.0 - ((-cos(a) / sin(a)) * (w / 2.0) + (w / 2.0) / sin(a))

        print(w * h - x1 * y1 - x0 * y0)
    else :
        y = tan(a) * (w / 2.0) - (h / 2.0) / cos(a) + h / 2.0
        y0 = y - h
        x0 = y * tan(pi / 2.0 - a)
        print(w * h - (y0 * tan(pi / 2.0 - a) + x0) * h)
    




from math import cos, pi, sin, atan
W, H, b = map(float, input().split())
a = (b/180)*pi

if (W < H):
    X = W
    W = H
    H = X

if (a > 0.5*pi):
    a = 0.5*pi - (a - 0.5*pi)

opp = W*H
if (a == 0):
    eindopp = W*H
else:
    if a > (atan(H/W)*2):
        Schuin = H/sin(a)
        eindopp = Schuin*H
    else:
        y = -2*cos(a)-cos(a)**2-1+sin(a)**2
        hks = (W*sin(a)-H*cos(a)-H)/y
        hgs = (H-hks-hks*cos(a))/sin(a)
        
        eindopp = opp - hks*sin(a)*hks*cos(a) - hgs*sin(a)*hgs*cos(a)


print(round(eindopp,9))