About the maximum uncomposite Number of the mass numbers in Number Theory

Source: Internet
Author: User

Recently I read the number theory and re-thought about this question. I referred to the paper and the lrj black book, re-proved it, and made a note.

Example: hdoj 1792 a new change problem
Given the interconnectivity between A and B, A and B, the maximum and maximum numbers cannot be combined.

Basic knowledge:
Gcd (a, B) = 1 → lcm (a, B) = AB
The remainder class, which divides all integers into M equivalence classes. Each equivalence class is composed of integers with the same number.

Any number is divided into M remainder classes, which are MK, Mk + 1, Mk + 2 ,......, Mk + (m-1)
Respectively recorded as {0 (mod m)}, {1 (mod m )}......
The multiples of N must be distributed in the M remainder class.
Because gcd (m, n) = 1, each remainder class has a number that is a multiple of N and is an evidence of its distribution on average. We can see that hdoj 1222 Wolf and rabbit
Set kmin = min {k | NK ε {I (mod m) }}, iε [0, m)
Nkmin is the minimum multiple of N in {I (mod m. Particularly, Nm ε {0 (mod m )}
Nkmin is a sign, which indicates all the numbers after nkmin in {I (mod m)}, that is, nkmin + JM must be combined.
It also indicates that the maximum number of combinations cannot be less than nkmin.
Let's start searching for max {nkmin}
LCM (m, n) = Mn, so obviously (S-1) n is the largest
Because m-1) n is the maximum value in nkmin, so M-1 1 residual classes, there must be smaller than it and can be M and N combination, these numbers are m-1) n-1, m-1) N-2 ,......, M-1) N-(m-1)
Therefore, the maximum number of combinations cannot be (m-1) N-M.

If m and n are not mutually exclusive, {1 (mod m)} cannot be combined by M, nor can it be combined by N and M.

After we can find the nkmin of each residue class, the number that cannot be combined is the sum of the numbers of each remainder class smaller than their respective nkmin.
Observe the following:
M = 5, n = 3
{0 (mod 5 )}:0, 5, 10, 15 ......
{1 (mod 5)}: 1,6......
{2 (mod 5) }:2,7,12, 17 ......
{3 (mod 5 )}:3, 8, 13, 18 ......
{4 (mod 5)}: 4,9......
Red indicates that the number cannot be combined. It can be seen that the number of remaining classes is regular.
Total = [0 + 1 + 2] + [0 + 1]
Because m and n are mutually qualitative, there must be an incomplete cycle
After sorting, you can obtain the formula Total = (n-1) * m-1)/2.

 

# Include <cstdio>

Int main ()
...{
Int A, B;
While (scanf ("% d", & A, & B) = 2 )...{
Printf ("% d", (A-1) * B-(A-1)-1, (A-1) * (b-1)/2 );
}
}

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.