This is a number topic that I figured out today. It was quite interesting. yeah came up with it for a moment. However, I had to pay for my carelessness in the tragedy three times, nm data center Blank
All cells are wrong, and I forgot to empty the lines. Clearly the string starts from 25 columns and has four spaces in the middle. I typed five spaces for nc and then pe, there are also requirements for not looking at the output carefully, no output is empty
OK. It's not in the status recently.
In fact, it is easy to figure out this question. It is also the concept of group in number theory, that is, the group generated by the addition group. It is just a fake random number. Because there is no seed limit
There is no impact on the answer. If the seed is 0, the series can be expressed as a * step. The series must be able to generate all numbers in 0-mod-1, then there is a * step = B % mod
(0 <= B <mod ).
Haha, the formula above is a * x = B % n linear homogeneous equation, but there are a lot of B. Do you need to solve the equation, not meet the condition gcd (a, n) | B?
Gcd (a, n) is an integer multiple. But 0 <= B <n, B will be 1, so gcd (a, n) must be 1. Then you can directly determine whether gcd (step, mod) is 1. Haha.
For linear homogeneous equations a * x = B % n, the conditional gcd (a, n) | B must be interpreted. For more information, see Introduction to algorithms or other materials...
The code is very simple, as follows:
# Include <stdio. h>
# Include <algorithm>
Using namespace std;
Int gcd (int a, int B)
{
If (a <B) swap (a, B );
While (B)
{
Int t =;
A = B;
B = t % B;
}
Return;
}
Int main ()
{
Int nStep, nMod;
While (scanf ("% d", & nStep, & nMod) = 2)
{
Printf ("% 10d % 10d % s \ n", nStep, nMod,
Gcd (nStep, nMod) = 1? "Good Choice": "Bad Choice ");
}
Return 0;
}