why isnt this code correct? when i check it myself it give correct values but here...
1.Program Trojke;
2.Var
3.n,i,p:longint;
4.niz:array[1..30000] of longint;
5.Procedure razmeni(Var a,b:longint);
6.Var
7.c:longint;
8.Begin
9. c:=a;
10. a:=b;
11. b:=c;
12.End;
13.Procedure sort;
14.Var
15.k,max,l:longint;
16.Begin
17. for k:=1 to n-2 do
18. Begin
19. max:=k;
20. for l:=k+1 to n do
21. Begin
22. if niz[l]>niz[max] then max:=l;
23. End;
24. if max<>k then razmeni(niz[k],niz[max]);
25. p:=(p+(niz[k] mod 10007*((n-k) mod 10007*(n-k-1) mod 10007) div 2) mod 10007) mod 10007;
26. End;
27.End;
28.Begin
29. readln(n);
30. for i:=1 to n do readln(niz[i]);
31. sort;
32. writeln(p);
33.End.
this is the problem
http://z-tre
ning.com/tasks.php?show_task=5000000125
1.Program Trojke;
2.Var
3.n,i,p:longint;
4.niz:array[1..30000] of longint;
5.Procedure razmeni(Var a,b:longint);
6.Var
7.c:longint;
8.Begin
9. c:=a;
10. a:=b;
11. b:=c;
12.End;
13.Procedure sort;
14.Var
15.k,max,l:longint;
16.Begin
17. for k:=1 to n-2 do
18. Begin
19. max:=k;
20. for l:=k+1 to n do
21. Begin
22. if niz[l]>niz[max] then max:=l;
23. End;
24. if max<>k then razmeni(niz[k],niz[max]);
25. p:=(p+(niz[k] mod 10007*((n-k) mod 10007*(n-k-1) mod 10007) div 2) mod 10007) mod 10007;
26. End;
27.End;
28.Begin
29. readln(n);
30. for i:=1 to n do readln(niz[i]);
31. sort;
32. writeln(p);
33.End.
this is the problem
http://z-tre
ning.com/tasks.php?show_task=5000000125