Skip to content

Instantly share code, notes, and snippets.

@uchidama
Created July 13, 2021 08:11
Show Gist options
  • Save uchidama/fd03d06c1c3fb9dd2f71dd20b26b4160 to your computer and use it in GitHub Desktop.
Save uchidama/fd03d06c1c3fb9dd2f71dd20b26b4160 to your computer and use it in GitHub Desktop.
AtCoder Beginner Contest 168 [ C - : (Colon) ] https://atcoder.jp/contests/abc168/tasks/abc168_c
'''
[問題]
https://atcoder.jp/contests/abc168/tasks/abc168_c
'''
import sys
import math
sys.setrecursionlimit(10 ** 6) # 再帰上限の引き上げ
input = sys.stdin.readline
INF = 2 ** 63 - 1
A, B, H, M = map(int, input().split())
# 時針の位置
h_shita = (H * 60 + M)/(12 * 60)
h_x = A * math.cos(2 * math.pi * h_shita)
h_y = A * math.sin(2 * math.pi * h_shita)
# 分針の位置
m_shita = M/60
m_x = B * math.cos(2 * math.pi * m_shita)
m_y = B * math.sin(2 * math.pi * m_shita)
# 距離の計算
ans = math.sqrt( (h_x - m_x) ** 2 + (h_y - m_y) ** 2)
print(ans)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment