Find Angle MBC

  • + 0 comments

    A different solution without tangent.

    import math
    
    def main():
        # a = AB and b = BC
        a, b = int(input()), int(input())
        # c = AC (hypotenuse)
        c = math.hypot(a, b)
    
        # Calculate angle A (opposite side a)
        # using the law of cosines
        cos_A = (b**2 + c**2 - a**2) / (2 * b * c)
        angle_A_rad = math.acos(cos_A)
        angle_A_deg = math.degrees(angle_A_rad)
        print(f"{round(angle_A_deg)}\u00B0")
    
    if __name__ == "__main__":
        main()