Basic modulo operations

Source: Internet
Author: User

2016.1.26

First popularity: A≡b (mod m) means that the remainder of a and B modulo m is equal

The remainder of a modulo m is recorded as a mod m (the naïve I thought that the three-bar above is to take the meaning of the remainder of the mold ( ̄▽ ̄)

Then the formula: Suppose A≡c (mod m) b≡d (mod m)

Then A+b≡c+d (mod m)

a-b≡c-d (mod m)

A*b≡c*d (mod m)

(These formulas will know why if you think about it)

Special Note: #一般在c + + in the negative results are negative, as long as the a%m+m can be changed.

#在答案爆不了int的情况下, the multiplication in the process can also explode int, so you can open long long ahead of time.

#加减乘都有方便使用的公式, but division is not, this matter next time.

Basic modulo operations

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.