记录编号 | 22129 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | 教官 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | Pascal | 运行时间 | 0.047 s | ||
提交时间 | 2010-11-17 11:52:54 | 内存使用 | 0.27 MiB | ||
program officer(input,output); var n,o:longint; a:array[1..10000]of int64; f:array[1..10000]of boolean; p:array[1..10000]of int64; head,i,j:longint; ans:int64; flag:boolean; procedure dg(x:longint;y:int64;z:longint); begin if y=x then begin inc(head); p[head]:=z; end else begin f[y]:=true; dg(x,a[y],z+1); end; end; function pro(x,y:int64):int64; var g:longint; begin if y>x then begin g:=y; y:=x; x:=g; end; if x mod y=0 then o:=y else begin pro(y,x mod y); end; end; begin assign(input,'officer.in'); reset(input); readln(n); for i:=1 to n do readln(a[i]); close(input); for i:=1 to n do if f[i]=false then begin f[i]:=true; dg(i,a[i],1); end; ans:=1; for i:=1 to head do begin o:=0; pro(ans,p[i]); ans:=(ans*p[i]) div o; end; assign(output,'officer.out'); rewrite(output); writeln(ans); close(output); end.