Problem understanding solution for round #383 (div 2) problem C

Revision en1, by Lance_HAOH, 2016-12-09 13:59:23

This was the given solution for round #383 (Div 2) problem C:

The problem statement: Here

The solution:

Make a directed graph and put edge from i and crushi. If the graph has vertex such that its in-degree is 0 then obviously answer doesn't exists. Otherwise the graph consists of some cycles. For each cycle suppose that its length is len. If it has odd length, add len to S, otherwise, add len / 2.

Answer is the LCM of numbers in S.

I am unsure why the LCM is the answer. Is anyone able to advise me?

Tags #round383, #math, #problem c, #graph

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Lance_HAOH 2016-12-09 13:59:23 629 Initial revision (published)