编程介的小学生 2017-09-08 15:02 采纳率: 20.5%
浏览 955
已采纳

General Simple Partial Fraction Decomposition

It is easy to obtain (6x2-5x-5)/(x3-2x2-x+2) from 1/(x+1) + 2/(x-1) + 3/(x-2). But how about the other way around?

Given a rational function in the form

where bn is 1. The simple partial fraction decomposition is given by

for some constants Ai and ri (i=1, 2, ..., n). Assume that the denominator has n integer roots. Your job is to compute the partial fraction of R(x).
Input
The input consists of several test cases. For each case, the first line contains a positive integer n which is the degree of the polynomial in the denominator of R(x). The following two lines contain integers { a0, a1, ..., an-1 } and { b0, b1, ..., bn-1 } respectively.
Output
For each test case, first output in a line { r1, r2, ..., rn } in non-decreasing order. Then if there is a partial fraction, output in the next line { A1, A2, ..., An }; otherwise print "No simple partial fraction".
It is guaranteed that the denominator of R(x) has only integer roots. Ai's must be accurate up to 2 decimal places. All the numbers must be separated by exactly one space, and no extra space is allowed at the end of the lines.
The output of two consecutive cases must be separated by a blank line. No extra line is allowed at the end of the outputs.

Sample Input:

3
-5 -5 6
2 -1 -2
3
-5 -3 5
2 -1 -2
2
-1 1
1 2
Sample Output:
-1 1 2
1.00 2.00 3.00

-1 1 2
0.50 1.50 3.00

-1 -1
No simple partial fraction

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-09-24 00:33
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿