https://www.acmicpc.net/problem/9772
9772번: Quadrants
Given the coordinates (x,y) of some points in 2-dimensional plane, find out which quadrant(Q1-Q4) the points are located. If a point is located on X-axis or Y-axis, print out AXIS instead.
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
def sol(x, y):
if x == 0 or y == 0:
return 'AXIS'
elif x > 0 and y > 0:
return 'Q1'
elif x < 0 and y > 0:
return 'Q2'
elif x < 0 and y < 0:
return 'Q3'
elif x > 0 and y < 0:
return 'Q4'
if __name__ == '__main__':
while True:
x, y = map(float, input().split())
print(sol(x, y))
if x == 0 and y == 0:
break
|
cs |
단순하게 사분면 구하는 문제입니다.
It's a simple quadrant problem.
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2. Add Two Numbers (0) | 2023.02.17 |
---|---|
leetcode 206. Reverse Linked List (0) | 2023.02.17 |
leetcode 989. Add to Array-Form of Integer (0) | 2023.02.15 |
leetcode 21. Merge Two Sorted Lists (0) | 2023.02.13 |
leetcode 1523. Count Odd Numbers in an Interval Range (0) | 2023.02.13 |
댓글