No.750 Frac #1
Problem Statement
You are given $n$ distinct fractions in the following format, each of which is an irreducible fraction, a fraction whose numerator is $0$, or a fraction whose denominator is $1$.
$\Large{ \cfrac{ A_1 }{ B_1 } , \ \cfrac{ A_2 }{ B_2 } , \ \cdots \cfrac{ A_n }{ B_n } }$
Sort the given fractions in descending order.
Input
$n$
$\! \begin {align} A_1 & \ B_1 \\ A_2 & \ B_2 \\ & \vdots \\ A_n & \ B_n \end {align}$
The input consists of integers satisfying the following constraints.
Here, $1 \leq i , \ j \leq n$.
Output
Output the given fractions in descending order, separated by newlines, each in the format "numerator denominator".
Sample
Sample 1
Input
6
4 5
3 7
3 4
-2 3
9 1
3 8
Output
9 1
4 5
3 4
3 7
3 8
-2 3
$\Large{ \cfrac{ 9 }{ 1 } \gt \cfrac{ 4 }{ 5 } \gt \cfrac{ 3 }{ 4 } \gt \cfrac{ 3 }{ 7 } \gt \cfrac{ 3 }{ 8 } \gt \cfrac{ -2 }{ 3 } }$
Sample 2
Input
3
3 7
1 1
5 3
Output
5 3
1 1
3 7
$\Large{ \cfrac{ 5 }{ 3 } \gt \cfrac{ 1 }{ 1 } \gt \cfrac{ 3 }{ 7 } }$
Sample 3
Input
6
1 1
7 4
0 5
1 3
-8 9
5 1
Output
5 1
7 4
1 1
1 3
0 5
-8 9
$\Large{ \cfrac{ 5 }{ 1 } \gt \cfrac{ 7 }{ 4 } \gt \cfrac{ 1 }{ 1 } \gt \cfrac{ 1 }{ 3 } \gt \cfrac{ 0 }{ 5 } \gt \cfrac{ -8 }{ 9 } }$
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。