### Блог пользователя Tobby_And_Friends

Автор Tobby_And_Friends, история, 16 месяцев назад, ,

I understand that the for n == m answer is 2. But I can't figure out the solution when n != m. I mean I basically do not understand the theory behind the solution (apart from trying out for small test cases). Any help is really appreciated.

 » 16 месяцев назад, # |   0 Let's decrease all numbers by 1 as real programmers do :).Now we can observe that if we had a number x on some place then after one permutation we have . Now we just want to know what is the minimum power of n which gives 1 modulo nm - 1.A similar problem but harder: Problem B
•  » » 16 месяцев назад, # ^ |   0 If it is not too much of a trouble can you please elaborate a bit? I could not understand to be honest. :( :'(
•  » » » 16 месяцев назад, # ^ |   0 Look at the first picture 9*3. We see that 3 becomes 1 (I calculate with 1 decreased from every number — actually it's 4 becomes 2). Now let's see that . The same could be observed for every other number except the one in the right bottom.Now let's take 1. We want for some number of multiplications. That's what I meant saying about lowest power of n.
 » 16 месяцев назад, # |   0 Observe grid when n=m. In this case answer is always 2. If n!=m if you look some cases you will see answer is n+m. Good luck :)
•  » » 4 месяца назад, # ^ |   0 TooNewbie your concept is totally wrong.. :)