Solution to number theory-N element Linear coordinalequations

Source: Internet
Author: User
 

Note: Due to the special nature of programming, the linear homogeneous equation of N element is rarely used in ACM. I learned it out of interest.

The concept of linear homogeneous equation of N element: 

For example: (A1 * X1 + A2 * X2 + .... + an * XN) % m = B % m .................. (1)

Of course there are also many variants, such as A1 * X1 + A2 * X2 +... + an * xn + M * x (n + 1) = B. both are equivalent.

Determine whether there is a solution:

To solve a linear homogeneous equation, we must first determine whether the equation has a solution. The Sufficient Condition for the equation to have a solution is: d % B = 0. where d = gcd (A1, A2 ,... an );

To solve the linear homogeneous equation of N yuan, we convert it into an Indefinite Equation of N yuan.

A1 * X1 + A2 * X2 +... + an * xn + M * x (n + 1) = B ................... (2)

It is not hard to prove that (2) and (1) are completely equivalent. The specific proof is also very simple, so we will not prove it here.

(2) The required and sufficient conditions for the solution are: d1 % B = 0. D1 = gcd (A1, A2,... an, m ).

Theorem: when (1) has a solution, there are D1 * m ^ (n-1) different solutions.

Theorem: when (1)

 

Equation solving:

Set d1 = gcd (A1, A2,... an, m), and D1 % B = 0.

Take advantage of the same remainder type:

 

Solution to number theory-N element Linear coordinalequations

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.