[cpp]
why i am getting TLE?[/cpp]
Moderator: Board moderators
var a:array[1..100] of shortint;
b:array[1..100] of byte;
i,j,u,z,k,n,r,l:longint;
begin
b[1]:=1;
repeat
inc(i);
readln(a[i]);
until a[i]=0;
n:=i-1;
for i:=1 to n do begin
r:=a[i];
j:=1;
repeat
inc(j);
l:=1;
k:=1;
for z:=2 to r do
b[z]:=0;
repeat
u:=0;
repeat
inc(l);
if l=r+1 then begin
l:=1;
repeat
inc(l);
until b[l]=0;
end;
if b[l]=0 then inc(u);
until u=j;
b[l]:=1;
inc(k);
until k=r;
until l=2;
a[i]:=j;
end;
for i:=1 to n do
writeln(a[i]);
readln;
end.

Users browsing this forum: No registered users and 0 guests