print1456. Calculate a limit

printCalculate a limit

Ограничения: время – 1s/2s, память – 64MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

Your program must calculate the value of `lim_{x->oo}\ {a_1\ x\ +\ a_2\ x^2\ +\ …\ +\ a_n\ x^n}/{b_1\ x\ +\ b_2\ x^2\ +\ …\ +\ b_n\ x^n}`
All coefficients are integers, so the answer must be calculated exactly and presented in the form of irreducible fraction.
Input file format
Input file contains integer `n` followed first by `n` integers `a_1\ a_2\ …\ a_n` and then by `n` integers `b_1\ b_2\ …\ b_n`.
Output file format
Output file must contain two integers – nominator and denominator of the fraction. If the limit is zero, output integers `0\ 1`. If the limit is infinity, output integers `1\ 0`.
Constraints
`1\ ≤\ n\ ≤\ 100`, `0\ ≤\ a_i,\ b_i\ ≤\ 10^9`, `sum_i\ (b_i\ +\ a_i)\ >\ 0`

Sample Input 1

1
2 4

Sample Output 1

1 2

Sample Input 2

2
0 1
1 0

Sample Output 2

1 0
Source: NEERC ICPC, Far Eastern subregion, 2009
loading