ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1024. Permutations

1 - 2 3 1 4 5
2 - 3 1 2 4 5
3 - 2 3 1 4 5


1 and 3 are same
No, 3-1 2 3 4 5. The digit always mean index for the first line.
but i can't find answer  3 with LCM?
2&3&1 is a loop with length 3
4 is a loop with length 1
5 is a loop with length 1
LCM(3,1,1)=3
2&3&1 is a loop with length 3

Edited by author 19.08.2010 16:11
ok.I understood.

Edited by author 19.08.2010 16:21
Say it in this way:
select an arbitraty number n, let i=n;
while( P(i)!=n ) i=P(i);
all the numbers "involved" makes a loop.

in case 2 3 1
select n=2,i=2;
P(i)=3 so i=3;
P(i)=1 so i=2;
now i=n, exit loop;

You can prove the following statement:
if a loop has X elements, then after exactly X permutations, every elements in the loop is on its proper position in EN.

is that clear? Since you are very good in maths, you may prove it yourself.
yes my math is good. But i begun to learn programming since 18.
Due to it I am not very good at finding algorythm.
Do you know really good book with examples for learning algorythms.
Sorry I only know books written in Chinese.
May be it is translation from English or Russian
All I know are written by Chinese authors.
Andrew Hoffmann aka SKYDOS [Vladimir SU] Re: I can't undertand it : 2&3&1 is a loop with length 3 // Problem 1024. Permutations 19 Aug 2010 16:47
cormen introduction to algorithms (pdf)
Knuth and other)
T_be_GP wrote 19 August 2010 16:28
yes my math is good. But i begun to learn programming since 18.
Due to it I am not very good at finding algorythm.
Do you know really good book with examples for learning algorythms.