比赛 |
20101117 |
评测结果 |
AAAAAAAAAA |
题目名称 |
教官 |
最终得分 |
100 |
用户昵称 |
Des. |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-17 08:52:17 |
显示代码纯文本
program officer;
var a,b:array[1..10000]of integer;
t,k,m,n,i,j:longint;
an:int64;
p:boolean;
function min(a,b:int64):int64;
begin
if a>b then min:=b else min:=a;
end;
function max(a,b:int64):int64;
begin
if a>b then max:=a else max:=b;
end;
function gcd(a,b:int64):int64;
var t,k:int64;
begin
t:=max(a,b);
k:=min(a,b);
if k=0 then gcd:=t
else gcd:=gcd(k,t mod k);
end;
procedure sou(i,s,j:longint);
var t,k:longint;
begin
b[i]:=1;
if a[i]=j then
begin
an:=(an*s)div(gcd(an,s));
exit;
end;
sou(a[i],s+1,j);
end;
begin
assign(input,'officer.in');
reset(input);
assign(output,'officer.out');
rewrite(output);
readln(n);
for t:=1 to n do
readln(a[t]);
an:=1;
{repeat
readln(i,j);
writeln(gcd(i,j));
until (i=0)and(j=0);}
for t:=1 to n do
if b[t]=0 then
begin
b[t]:=1;
if a[t]<>t then
sou(a[t],2,t);
end;
writeln(an);
close(output);
end.