Codeforces Round 124 (Div. 2)
B
Limit
Codeforces
1400
原题
← AC →
翻译中…

You are given two polynomials:

翻译中…
  • $*P*(*x*) = *a*_{0}·*x*^{*n*} + *a*_{1}·*x*^{*n* - 1} + ... + *a*_{*n* - 1}·*x* + *a*_{*n*}$ and
  • $*Q*(*x*) = *b*_{0}·*x*^{*m*} + *b*_{1}·*x*^{*m* - 1} + ... + *b*_{*m* - 1}·*x* + *b*_{*m*}$.
翻译中…

Calculate limit image.

翻译中…

Input

翻译中…

The first line contains two space-separated integers $*n*$ and $*m*$ ($0 ≤ *n*, *m* ≤ 100$) — degrees of polynomials $*P*(*x*)$ and $*Q*(*x*)$ correspondingly.

翻译中…

The second line contains $*n* + 1$ space-separated integers — the factors of polynomial $*P*(*x*)$: $*a*_{0}$, $*a*_{1}$, ..., $*a*_{*n* - 1}$, $*a*_{*n*}$ $( - 100 ≤ *a*_{*i*} ≤ 100, *a*_{0} ≠ 0)$.

翻译中…

The third line contains $*m* + 1$ space-separated integers — the factors of polynomial $*Q*(*x*)$: $*b*_{0}$, $*b*_{1}$, ..., $*b*_{*m* - 1}$, $*b*_{*m*}$ $( - 100 ≤ *b*_{*i*} ≤ 100, *b*_{0} ≠ 0)$.

翻译中…

Output

翻译中…

If the limit equals $+ ∞$, print "Infinity" (without quotes). If the limit equals $- ∞$, print "-Infinity" (without the quotes).

翻译中…

If the value of the limit equals zero, print "0/1" (without the quotes).

翻译中…

Otherwise, print an irreducible fraction — the value of limit image, in the format "p/q" (without the quotes), where $*p*$ is the — numerator, $*q*$ $(*q* > 0)$ is the denominator of the fraction.

翻译中…

Note

翻译中…

Let's consider all samples:

翻译中…
  1. image
  2. image
  3. image
  4. image
  5. image
翻译中…

You can learn more about the definition and properties of limits if you follow the link: http://en.wikipedia.org/wiki/Limit_of_a_function

翻译中…

样例

Input #1
2 1
1 1 1
2 5
Output #1
Infinity
InputCopy OutputCopy
Input #2
1 0
-1 3
2
Output #2
-Infinity
InputCopy OutputCopy
Input #3
0 1
1
1 0
Output #3
0/1
InputCopy OutputCopy
Input #4
2 2
2 1 6
4 5 -7
Output #4
1/2
InputCopy OutputCopy
Input #5
1 1
9 0
-5 2
Output #5
-9/5
InputCopy OutputCopy
题目信息
题号
197B
时间限制
2 s
内存限制
256 MB
标签
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。