Problem p02677 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math

def input():
    return sys.stdin.readline()


def calc_coord(theta, length):
    # 第一象限
    if 0 <= theta <= 90:
        rad1 = round(math.radians(90-theta), 11)
        min_x = length * round(math.cos(rad1), 11)
        min_y = length * round(math.sin(rad1), 11)
    elif 90 < theta <= 180:
        rad1 = round( math.radians(90 - theta), 11)
        min_x = round(length * math.cos(rad1),11)
        min_y = round(length * math.sin(rad1),11)
    elif 180 < theta <= 270:
        rad2 = round(math.radians(450-theta),11)
        min_x = round(length * math.cos(rad2),11)
        min_y = round(length * math.sin(rad2),11)
    elif 270 < theta <= 360:
        rad2 = round(math.radians(450 - theta),11)
        min_x = round(length * math.cos(rad2),11)
        min_y = round(length * math.sin(rad2),11)

    return min_x, min_y


def resolve():
    a, b, h, m = map(int, input().split())

    # 時刻を角度に変換
    min_theta = 6.0 * m
    hour_theta = 30 * h + 0.5 * m

    min_x, min_y = calc_coord(min_theta, b)
    hour_x, hour_y = calc_coord(hour_theta, a)

    ans = math.sqrt((min_x - hour_x) ** 2 + (min_y - hour_y) ** 2)

    print(ans)

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math

def input():
    return sys.stdin.readline()


def calc_coord(theta, length):
    # 第一象限
    if 0 <= theta <= 90:
        rad1 = round(math.radians(90-theta), 11)
        min_x = length * round(math.cos(rad1), 11)
        min_y = length * round(math.sin(rad1), 11)
    elif 90 < theta <= 180:
        rad1 = round( math.radians(90 - theta), 11)
        min_x = round(length * math.cos(rad1),11)
        min_y = round(length * math.sin(rad1),11)
    elif 180 < theta <= 270:
        rad2 = round(math.radians(450-theta),11)
        min_x = round(length * math.cos(rad2),11)
        min_y = round(length * math.sin(rad2),11)
    elif 270 < theta <= 359:
        rad2 = round(math.radians(450 - theta),11)
        min_x = round(length * math.cos(rad2),11)
        min_y = round(length * math.sin(rad2),11)

    return min_x, min_y


def resolve():
    a, b, h, m = map(int, input().split())

    # 時刻を角度に変換
    min_theta = 6.0 * m
    hour_theta = 30 * h + 0.5 * m

    min_x, min_y = calc_coord(min_theta, b)
    hour_x, hour_y = calc_coord(hour_theta, a)

    ans = math.sqrt((min_x - hour_x) ** 2 + (min_y - hour_y) ** 2)

    print(ans)

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math

def input():
    return sys.stdin.readline()


def calc_coord(theta, length):
    # 第一象限
    if 0 <= theta <= 90:
        rad1 = math.radians(90-theta)
        min_x = length * math.cos(rad1)
        min_y = length * math.sin(rad1)
    elif 90 < theta <= 180:
        rad1 = math.radians(90 - theta)
        min_x = length * math.cos(rad1)
        min_y = length * math.sin(rad1)
    elif 180 < theta <= 270:
        rad2 = math.radians(450-theta)
        min_x = length * math.cos(rad2)
        min_y = length * math.sin(rad2)
    elif 270 < theta <= 359:
        rad2 = math.radians(450 - theta)
        min_x = length * math.cos(rad2)
        min_y = length * math.sin(rad2)

    return min_x, min_y


def resolve():
    a, b, h, m = map(int, input().split())

    # 時刻を角度に変換
    min_theta = 6.0 * m
    hour_theta = 30 * h + 0.5 * m

    min_x, min_y = calc_coord(min_theta, b)
    hour_x, hour_y = calc_coord(hour_theta, a)

    ans = math.sqrt((min_x - hour_x) ** 2 + (min_y - hour_y) ** 2)

    print(ans)

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math

def input():
    return sys.stdin.readline()


def calc_coord(theta, length):
    # 第一象限
    if 0 <= theta <= 90:
        min_x = length * math.cos(math.radians(90-theta))
        min_y = length * math.sin(math.radians(90-theta))
    elif 90 < theta <= 180:
        min_x = length * math.cos(math.radians(90-theta))
        min_y = length * math.sin(math.radians(90-theta))
    elif 180 < theta <= 270:
        min_x = length * math.cos(math.radians(270-(theta-180)))
        min_y = length * math.sin(math.radians(270-(theta-180)))
    elif 270 < theta <= 359:
        min_x = length * math.cos(math.radians(360-theta+90))
        min_y = length * math.sin(math.radians(360-theta+90))

    return min_x, min_y


def resolve():
    a, b, h, m = map(int, input().split())

    # 時刻を角度に変換
    min_theta = 6.0 * m
    hour_theta = 30 * h + 0.5 * m




    min_x, min_y = calc_coord(min_theta, b)
    hour_x, hour_y = calc_coord(hour_theta, a)

    ans = math.sqrt((min_x - hour_x) ** 2 + (min_y - hour_y) ** 2)

    print(ans)

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math

def input():
    return sys.stdin.readline()


def calc_coord(theta, length):
    # 第一象限
    if 0 <= theta <= 90:
        min_x = length * math.cos(math.radians(90-theta))
        min_y = length * math.sin(math.radians(90-theta))
    elif 90 < theta <= 180:
        min_x = length * math.cos(math.radians(90-theta))
        min_y = length * math.sin(math.radians(90-theta))
    elif 180 < theta <= 270:
        min_x = length * math.cos(math.radians(270-(theta-180)))
        min_y = length * math.sin(math.radians(270-(theta-180)))
    elif 270 < theta <= 359:
        min_x = length * math.cos(math.radians(360-theta+90))
        min_y = length * math.sin(math.radians(360-theta+90))

    return min_x, min_y


def resolve():
    a, b, h, m = map(int, input().split())

    # 時刻を角度に変換
    min_theta = 6.0 * m
    hour_theta = 30 * h + 0.5 * m




    min_x, min_y = calc_coord(min_theta, b)
    hour_x, hour_y = calc_coord(hour_theta, a)

    if min_x >= hour_x and min_y >= hour_y:
        ans = math.sqrt((min_x - hour_x) ** 2 + (min_y - hour_y) ** 2)
    elif min_x < hour_x and min_y >= hour_y:
        ans = math.sqrt((hour_x - min_x) ** 2 + (min_y - hour_y) ** 2)
    elif min_x >= hour_x and min_y < hour_y:
        ans = math.sqrt((min_x - hour_x) ** 2 + (hour_y - min_y) ** 2)
    else:
        ans = math.sqrt((hour_x - min_x) ** 2 + (hour_y - min_y) ** 2)
     
    print(ans)

if __name__ == "__main__":
    resolve()