Skip to content

Commit

Permalink
2024-08-17 7869 두 원
Browse files Browse the repository at this point in the history
  • Loading branch information
seongwon030 committed Aug 17, 2024
1 parent 67538f5 commit 43efbcf
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions seongwon030/μˆ˜ν•™/두 원.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import math

x1, y1, r1, x2, y2, r2 = map(float, input().split())

# 쀑심 κ°„ 거리
d = math.sqrt((x1 - x2)**2 + (y1 - y2)**2)


if r1+r2 <= d:
print(format(0,".3f"))
elif abs(r1-r2) >= d :
result = math.pi*min(r1,r2)**2
print( format(result,".3f"))
else:
t1 = math.acos((d**2+r1**2-r2**2) / (d*r1*2.0)) * 2.0
t2 = math.acos((d**2+r2**2-r1**2) / (d*r2*2.0)) * 2.0

result = (t1 * r1 * r1 + t2 * r2 * r2 - r1 * r1 * math.sin(t1) - r2 * r2 * math.sin(t2)) * 0.5
print(format(result,".3f"))

0 comments on commit 43efbcf

Please sign in to comment.