A8640 | Limit
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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)=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 .
输入格式
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)$ .
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)$ .
输出格式
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.
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.
输入输出样例
输入 #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:
1. 
2. 
3. 
4. 
5. 
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
1. 
2. 
3. 
4. 
5. 
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
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted