Hi there!
During preparation of Oleksandr Kulkov Contest 1 I started writing some template for polynomial algebra (because 3 problems in contest in one or another way required some polynomial operations). And with great pleasure I'd like to report that it resulted in this article on cp-algorithms.com (English translation for e-maxx) and this mini-library containing all mentioned operations and algorithms (except for Half-GCD algorithm). I won't say the code is super-optimized, but at least it's public, provides some baseline and is open for contribution if anyone would like to enhance it!
Article also provides some algorithms I didn't mention before. Namely:
- Interpolation: Now the described algorithm is
and not
as it was before. - Resultant: Given polynomials A(x) and B(x) compute product of A(μi) across all μi being roots of B(x).
- Half-GCD: How to compute GCD and resultants in
(just key ideas).
Feel free to read the article to know more and/or use provided code :)
tl;dr. article on operations with polynomials and implementation of mentioned algorithms.







as
.
if I'm not mistaken. Can anybody suggest any faster algorithm?


and multiplying it with
. Enjoy your power sums without Stirling and/or Bernoulli numbers!
.
correspond to segment
and the path from
) will be
subsegment which gives you the opportunity to process queries on pathes and subtrees simultaneously in the same segment tree.
?
? Can you prove it or make a counter-example?
online (ie, answer will be received for each prefix).
offline. The first algorithm with such an assessment was offered by David Eppstein in 1992, reducing it to fully dynamic minimum spanning tree problem, but here we will focus on a simple algorithm, proposed in 2012 by Sergei 