编程介的小学生 2019-09-22 22:53 采纳率: 20.5%
浏览 78

Maclaurin Series of Reciprocals 利用C语言实现

Description

Any function f(x) that is infinitely differentiable in the neighborhood of the point x = 0 can be expanded into a Maclaurin series

f(0)+\frac{f'(0)}{1!}x+\frac{f''(0)}{2!}x^2+\frac{f^{(3)}(0)}{3!}x^3+\cdots,
or more compactly,

\sum_{k=0}^{\infty}\frac{f^{(k)}(0)}{k!}x^k.
Under certain conditions, f(x) is equal to its Maclaurin series for all x sufficiently close to 0.

Often, the Maclaurin series of f(x) is written up to only order xn-1 with a Peano remainder term, i.e., 

\sum_{k=0}^{n-1}\frac{f^{(k)}(0)}{k!}x^k+\mathcal{O}(x^n),
which facilitates the evaluation of f(x). The series being truncated to the xn-1 term, details about higher-order terms are inevitably lost. However, certain information concerning the series remains well-preserved. For instance, the Maclaurin series of 1/f(x) with an identical Peano remainder term can still be found.

Given the Maclaurin series of a function f(x) with a Peano remainder term, determine that of the reciprocal of f(x).

Input

The input consists of a single test case.

The first line contains an integer n (1 ≤ n ≤ 100). Each of the next n lines contains a fraction pk/qk (0 ≤ k ≤ n - 1) where pk and qk (-100 ≤ pk ≤ 100, 1 ≤ qk ≤ 100) are integers coprime to each other in the form either pk/qk (if qk ≠ 1) or pk (if qk = 1). It is guaranteed that p0 ≠ 0.

The given numbers represent the Maclaurin series

\sum_{k=0}^{n-1}\frac{p_k}{q_k}x^k+\mathcal{O}(x^n)
of some function f(x).

Output

Let the Maclaurin series of 1/f(x) be

\sum_{k=0}^{n-1}\frac{p'_k}{q'_k}x^k+\mathcal{O}(x^n)
where qk' > 0, and pk' and qk' are integers coprime to each other. Output n lines each of the form either pk'/qk' (if qk' ≠ 1) or pk' (if qk' = 1), listing the coefficients of 1, x, x2, ... , xn-1 in order.

Sample Input

10
1/2
-46/3
9/40
61/80
-22/5
-87/41
1/11
-42/5
-4/13
-21/44
Sample Output

2
184/3
169199/90
6223213/108
28611844561/16200
107867589093163/1992600
545525329585163771/328779000
401297234058997162673/7890696000
2398505849871035056778279/1538685720000
882189800570641237196128639/18464228640000

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c程序不知道为什么得不到结果
    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置