Luo Gu $ P5330 \ [SNOI2019] $ Number Theory Number Theory

Correct answer: number theory

Report problem solving:

Portal $ QwQ $

This problem is quite wonderful QwQ $ $ (,,, in fact, all came to me several topics wonderful $ kk $

Consider first built $ Q $ points, numbered $ [0, Q) $, represents the remainder membrane $ Q $ Then each point $ I $ to $ (i + P) \ mod Q $ connected side $ QwQ $

Obviously, this will ring, in fact, the length of the ring on the $ \ frac {P \ cdot Q} {gcd (P, Q)} $ (Kang do not understand can go that road very old-fashioned test over several times a run that's a problem? it is not a question permit the conclusion is said in the film $ Q $ significance of each pass $ P $, there will only be $ gcd (P, Q) $ ring Well, put this question where there is $ gcd (P, Q) $ length of $ \ frac {P \ cdot Q} {gcd (P, Q)} $ $ QwQ $ cycloalkyl

$ P $ then enumerate membrane remainder $ $ a_i, while running along apparently equivalent to $ $ a_i constant, then it becomes now, it begins to run $ $ \ lfloor \ frac a_i in the ring from $ {T- 1-a_i} {P} \ rfloor $ step, is asked how many steps the number of film ran $ Q \ point on in B $ $ QwQ $

Therefore, considering the number to the number of pre-$ B $ belonging to one of the rings, and then the last remaining little on the tail of special operator Oak

$over$!

I understand that I spent half a day $ QAQ $

Guess you like

Origin www.cnblogs.com/lqsukida/p/11568768.html
Recommended