본문 바로가기
python-algorithm

백준 9772 Quadrants

by 무적김두칠 2023. 2. 17.

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.

반응형

댓글