# Kattis - quadrant [題目連結](https://open.kattis.com/problems/quadrant) ## 題目敘述 A common problem in mathematics is to determine which quadrant a given point lies in. There are four quadrants, numbered from $1$ to $4$, as shown in the diagram below: ![](https://i.imgur.com/rJUjjCH.png) For example, the point $A$, which is at coordinates $(12,5)$ lies in quadrant $1$ since both its $x$ and $y$ values are positive, and point $B$ lies in quadrant $2$ since its $x$ value is negative and its $y$ value is positive. Your job is to take a point and determine the quadrant it is in. You can assume that neither of the two coordinates will be $0$. :::success 一個數學上常見的問題是給你一個座標點,問你這個點落在第幾象限上。 象限被編號為 $1$ 到 $4$,如圖所示。 (見上圖) 例如座標為 $(12,5)$ 的點 $A$ 因為 $x$ 和 $y$ 皆為正數,因此落在第一象限; 而點 $B$ 因 $x$ 為負、$y$ 為正,因此落在第二象限。 你的任務是對給予的點座標,計算出它落在第幾象限上。 題目保證 $x$ 和 $y$ 都不會是 $0$。 ::: ## 輸入格式 The first line of input contains the integer $x$ $(−1000\le x\le 1000;x\ne 0)$. The second line of input contains the integer $y$ $(−1000\le y\le 1000;y\ne 0)$. :::success 輸入第一行包含一整數 $x$ 保證 $(−1000\le x\le 1000;x\ne 0)$; 第二行包含一整數 $y$ 保證 $(−1000\le y\le 1000;y\ne 0)$。 ::: ## 輸出格式 Output the quadrant number $(1, 2, 3$ or $4)$ for the point $(x,y)$. :::success 對於點 $(x,y)$ 輸出它所在象限 $(1, 2, 3$ 或者 $4)$ ::: ## Sample Input ``` 10 6 ``` ## Sample Output ``` 1 ``` ## Sample Input ``` 9 -13 ``` ## Sample Output ``` 4 ``` {%hackmd @sa072686/__style %} ###### tags: `翻譯`, `Kattis`