Accepted
/usr/bin/ld.bfd: warning: /out/link.res contains output sections; did you forget -T?
代码
var n,i,j,s,cnt,sum,ans,next,b:longint;
a:array[1..100000]of longint;
u:array[1..100000]of boolean;
procedure swap(var a,c:longint);
var t:longint;
begin
t:=a; a:=c; c:=t;
end;
begin
readln(n);
for i:=1 to n do read(a[i]);
for i:=1 to n do begin
b:=i;
while a[b]<>b do begin
inc(cnt);
swap(a[b],a[a[b]]);
inc(ans);
end;
end;
writeln(ans);
close(input);
close(output);
end.