Cod sursa(job #46899)

Utilizator raduzerRadu Zernoveanu raduzer Data 3 aprilie 2007 10:33:06
Problema Order Scor 30
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.59 kb
var a:array[1..30000]of integer;
    n,i,j,x,s:integer;
begin
     assign(input,'order.in');
     reset(input);
     assign(output,'order.out');
     rewrite(output);
     readln(n);
     for i:=1 to n do a[i]:=i;
     i:=1;
     j:=1;
     x:=0;
     s:=0;
     while x<n do
     begin
          i:=i+1;
          if i>n then i:=1;
          if a[i]>0 then s:=s+1;
          if s=j then
          begin
               write(a[i],' ');
               a[i]:=-1;
               x:=x+1;
               j:=j+1;
               s:=0;
          end;
     end;
close(output);
end.