POJ 3735 Training Little Cats

Source: Internet
Author: User

Title Link: http://poj.org/problem?id=3735

The first idea is to build two (n+1) * (n+1) matrix A, the diagonal is 1, the other element is initially 0, the other (n+1) is the matrix B, for the element (b i1) ∈b,1<= i <=n (matrix element coordinates in the discussion with 1), Indicates the number of peanuts for the nth Cat, initially 0,b (n+1) 1=1.

For the G I operation, add (a I (n+1)) plus 1. ((AIJ) ∈ A)

For the E-I operation, the line I is fully zeroed.

For the S I j operation, the lines I and J are exchanged.

Thus, the modified matrix A to its M-power, and then multiplied by the matrix B to obtain a (n+1) * * of the Matrix , line I (1<= i <=n) indicates the number of the last peanut of the nth cat.

For the problem-like column, the calculation is as follows

Think carefully, the above matrix can be simplified, redefine (n+1) * (n+1) of the moment matrix A, diagonal is 1, for (a i1) ∈a,1<= i <=n the number of peanuts for the nth cat, initially 0.

For the G I operation, add (a I 1) plus 1.

For the E-I operation, the line I is fully zeroed.

For the S I j operation, the lines I and J are exchanged.

This method is equivalent to the previous one, the M power to A,(a i1) ∈am,1<= i <=n the number of peanuts for the nth cat.

POJ 3735 Training Little Cats

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.