-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbaekjoon1002
More file actions
156 lines (103 loc) · 2.22 KB
/
baekjoon1002
File metadata and controls
156 lines (103 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#case1
import math
def find_intersection(x1, y1, r1, x2, y2, r2):
d = math.sqrt(math.pow(x2-x1,2) + math.pow(y2-y1,2))
# 두 원이 겹칠 경우
if d == 0 and r1 == r2 :
return -1
# 내접하는 경우
elif d == abs(r1 - r2) and r1 != r2:
return 1
# 외접하는 경우
elif d == r1 + r2:
return 1
# 두 교점을 가지는 경우
elif (d < r1 + r2) and (d > abs(r1 - r2)):
return 2
# 그 외의 경우
else:
return 0
num = int(input("Enter the number of test cases: "))
result_list = []
for i in range(num):
x1, y1, r1, x2, y2, r2 = map(int, input().split())
result_list.append(find_intersection(x1, y1, r1, x2, y2, r2))
for i in result_list :
print(i)
#case2
import math
num = int(input())
for i in range(num) :
x1, y1, r1, x2, y2, r2 = map(int, input().split())
d = math.sqrt(math.pow(x2-x1,2) + math.pow(y2-y1,2))
# 두 원이 겹칠 경우
if d == 0 and r1 == r2 :
print(-1)
# 내접하는 경우
elif d == abs(r1 - r2) :
print(1)
# 외접하는 경우
elif d == r1 + r2:
print(1)
# 두 교점을 가지는 경우
elif d < (r1 + r2) and (d > abs(r1 - r2)):
print(2)
# 그 외의 경우
else:
print(0)
#references
3
0 0 13 40 0 37
0 0 3 0 7 4
1 1 1 1 1 5
2
1
0
파이썬 switch 문 없이 if문
교점 구하는 식??
case 별 구분
def inter1() :
d = |r1 + r2|
def inter0() :
d > |r1+ r2|
def inter_inner() :
d > |r1 - r2|
def inter_outer() :
d = |r1+ r2|
def inter_same() :
d= r1 = r2
https://blockdmask.tistory.com/522
https://jimmy-ai.tistory.com/184
sqrt 제곱근
pow 제곱
3
0 0 13 40 0 37
0 0 3 0 7 4
1 1 1 1 1 5
2
1
0
num = int(input())
for i in num:
x1, y1, r1, x2, y2, r2 = map(int, input().split())
d = math.sqrt(math.pow(x2-x1) + math.pow(y2-y1))
if (d > r1 + r2)
return 0
else if ( d = r1+ r2)
return 1
else if ( |r1-r2| < d < r1+r2 )
return 2
else if ( d = |r1-r2| )
return 1
else if ( d < |r1-r2| )
return 0
print(return)
"""
# 두 원이 만나지 않을 경우
if d > r1 + r2:
return 0
if abs(r1-r2) > d :
return 0
if d == 0 and r1!=r2 :
return 0
"""