Basic modulo operation, basic operation

Source: Internet
Author: User

Basic modulo operation, basic operation

2016.1.26

 

First popularized: a between B (mod m) means that the remainder of m of a and B is equal

The remainder of a modulo m is recorded as a mod m (naive I thought that the above three bars meant the remainder of the modulo)

Then there is the formula: assume a ≡ c (mod m) B ≡ d (mod m)

Then a + B then c + d (mod m)

A-B branch c-d (mod m)

A * B Branch c * d (mod m)

(Think about these formulas to find out why)

Note: # generally, the negative modulo result in c ++ is also a negative number. In this case, a % m + m can be changed to a positive value.

# In the case that the answer cannot blow up the int, the multiplication calculation in the process may also blow up the int, so long can be enabled in advance.

# Addition, subtraction, and multiplication all have easy-to-use formulas, but division is not the case. Let's talk about this next time.

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.