11th multiple schools and 3944 HDU dp (Lucas theorem, modulo of large groups)

Source: Internet
Author: User

The question is to walk along the vertex (0, 0) of the Yang Hui triangle and go to (n, k). Only (I, j)-> (I + 1, J) or (I, j)-> (I + 1, J + 1) Calculate the sum of all numbers in the path and find the path with the smallest weight;

The path with the smallest weight must first walk n-k along 1 on the left or 1 on the right, and convert K> n/2 to n-k, because the weights of the two paths are the same, the sum shows that the answer is C (n + 1, k) + n-k;

See brother Lu's bloghttp: // www.earthson.net/. lacuscheck and promotion, and there are powerful templates.

I picked a point where p is a small prime number, but it is still slow in time, if it is a constant...

 

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.