CF197B.Limit

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are given two polynomials:

  • P(x)=a0xn+a1xn1+...+an1x+anP(x)=a_{0}·x^{n}+a_{1}·x^{n-1}+...+a_{n-1}·x+a_{n} and
  • Q(x)=b0xm+b1xm1+...+bm1x+bmQ(x)=b_{0}·x^{m}+b_{1}·x^{m-1}+...+b_{m-1}·x+b_{m} .

Calculate limit .

输入格式

The first line contains two space-separated integers nn and mm ( 0<=n,m<=1000<=n,m<=100 ) — degrees of polynomials P(x)P(x) and Q(x)Q(x) correspondingly.

The second line contains n+1n+1 space-separated integers — the factors of polynomial P(x)P(x) : a0a_{0} , a1a_{1} , ..., an1a_{n-1} , ana_{n} (100<=ai<=100,a00)(-100<=a_{i}<=100,a_{0}≠0) .

The third line contains m+1m+1 space-separated integers — the factors of polynomial Q(x)Q(x) : b0b_{0} , b1b_{1} , ..., bm1b_{m-1} , bmb_{m} (100<=bi<=100,b00)(-100<=b_{i}<=100,b_{0}≠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 pp is the — numerator, qq (q>0) is the denominator of the fraction.

输入输出样例

  • 输入#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

首页