Cojs Crazy summation Problem solving report

Source: Internet
Author: User

Qaq long time no cojs on the question

Recently learned a bit of new technology, so it was a question to share

This question is required SIMGA (I^K)

So let's talk about some of the algorithms:

10 points:

Direct violence can be, Time complexity O (NLOGK)

30 points:

We consider setting s (n) to denote 1^k+2^k+......+n^k and

Not hard to find S (n+1) =s (n) + (n+1) ^k

By the two-term theorem (n+1) ^k=sigma (C (k,i) *n^i)

Construction Vector (N^0,n^1,n^2......,n^k,s (n))

It is not difficult to construct a transfer matrix based on the equation just now, then the matrix multiplication + fast power can be

Time complexity O (K^3LOGN)

60 points:

Set S (d) to denote 0^d+1^d+2^d+......+ (n-1) ^d and

Note (d+1) ^i-d^i = Sigma (C (I,J) *d^j) (where j is not equal to i)

If the value of D is 0-(n-1), we ask Sigma for the left-hand

We got the left-=n^i.

Sigma (C (i,j) * S (j)) (J<i) is obtained after the corresponding right-type pass-through simplification

So C (i,i-1) *s (i-1) =n^i-sigma (c (i,j) *s (j)) (J<i-1)

Since S (0) is known, we can deliver the results within O (k^2) time

80 points:

We define the Bernoulli number as B

Can get Sigma (i^k) = Sigma (C (k+1,j) * B (K+1-J) * (n+1) ^j)/(k+1)

If we can find the Bernoulli number quickly, then we can figure out the answer in O (k) time.

We know that the generating function of the Bernoulli number is x/(e^x-1)

When Taylor expands on e^x, we can get the X-ray out of it.

The generation function of the polynomial of the Bernoulli number 1/(x^i/(i+1)!)

Considering the polynomial of the denominator is very easy to find, and the Bernoulli number polynomial is the inverse of this polynomial

Polynomial inversion can be, Time complexity O (klogk), the constant is huge

100 Points:

From the surface we can actually know that Sigma (I^k) formula is actually a (i+1) polynomial

Set this polynomial to F

What we're actually asking for is f (x), which is the value of a point.

It is not difficult to find the value of each point of x= (0-> (k+1)) in the time of O (KLOGK)

Known k+2 point value, you can uniquely determine a polynomial of k+1 times

The value of f (n) can be obtained by directly substituting Lagrange interpolation formula

Notice that the time complexity of the direct use of the Lagrange interpolation formula is O (k^2)

But since we have a 1 difference in the x-coordinate of our neighbors.

The interpolation of O (k) can be done by preprocessing the inverse of factorial and factorial f (n)

Total time complexity O (KLOGK), but due to log acquisition is a fast power, so the constant is small

Cojs Crazy summation Problem solving report

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.