CF197B.Limit

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 .

给你两个多项式:

  • P(x)=a0⋅xn+a1⋅xn−1+⋯+an−1⋅x+anP(x) = a_0 \cdot x^n + a_1 \cdot x^{n-1} + \dots + a_{n-1} \cdot x + a_n,以及
  • Q(x)=b0⋅xm+b1⋅xm−1+⋯+bm−1⋅x+bmQ(x) = b_0 \cdot x^m + b_1 \cdot x^{m-1} + \dots + b_{m-1} \cdot x + b_m。

计算极限
。

输入格式

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).

第一行包含两个以空格分隔的整数 nn 和 mm(0 ≤ n, m ≤ 1000 \le n, m \le 100),分别表示多项式 P(x)P(x) 和 Q(x)Q(x) 的次数。

第二行包含 n + 1n + 1 个以空格分隔的整数——多项式 P(x)P(x) 的系数:a0,a1,…,an−1,ana_0, a_1, \dots, a_{n-1}, a_n(−100 ≤ ai ≤ 100-100 \le a_i \le 100,且 a0 ≠ 0a_0 \ne 0)。

第三行包含 m + 1m + 1 个以空格分隔的整数——多项式 Q(x)Q(x) 的系数:b0,b1,…,bm−1,bmb_0, b_1, \dots, b_{m-1}, b_m(−100 ≤ bi ≤ 100-100 \le b_i \le 100,且 b0 ≠ 0b_0 \ne 0)。

输出格式

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 , in the format "p/q" (without the quotes), where p is the — numerator, q (q > 0) is the denominator of the fraction.

如果极限等于 +∞+\infty,输出 "Infinity"(不带引号)。
如果极限等于 −∞-\infty,输出 "-Infinity"(不带引号)。

如果极限的值为零,输出 "0/1"(不带引号)。

否则,输出一个既约分数——即极限值 ,格式为 "p/q"(不带引号),其中 pp 为分子,qq(q>0q > 0)为分母。

输入输出样例

  • 输入#1

    2 1
    1 1 1
    2 5

    输出#1

    Infinity
  • 输入#2

    1 0
    -1 3
    2

    输出#2

    -Infinity
  • 输入#3

    0 1
    1
    1 0

    输出#3

    0/1
  • 输入#4

    2 2
    2 1 6
    4 5 -7

    输出#4

    1/2
  • 输入#5

    1 1
    9 0
    -5 2

    输出#5

    -9/5

说明/提示

Let's consider all samples:

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

我们来考虑所有样例:

如需进一步了解极限的定义与性质,请访问链接:http://en.wikipedia.org/wiki/Limit_of_a_function

输入解题思路,AI测评打分。不知道怎么写?

首页