Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Why TLE

Posted by yanghuan at 2006-11-15 23:27:49 on Problem 2769
Program Lx;
Var
  t, n, k, Max, i, j: Longint;
  a: Array[1..1000] Of Longint;
  b: Array[0..1000000] Of Boolean;
  f: Boolean;
Begin
  Readln(t);
  For i:=1 to t Do Begin
    Readln(n);
    Max := 0;
    For j:=1 To n Do Begin
      Read(a[j]);
      If (a[j] > Max) Then Max := a[j];
    End;
    Readln;
    For k:=1 To Max Do Begin
      f := True;
      Fillchar(b, Sizeof(b), False);
      For j:=1 To n Do Begin
        If (b[a[j] Mod k]) Then Begin f := False; Break; End;
        b[a[j] Mod k] := True;
      End;
      If (f) Then Begin Writeln(k); Break; End; 
    End;
  End;
End.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator