Cod sursa(job #46902)

Utilizator raduzerRadu Zernoveanu raduzer Data 3 aprilie 2007 10:38:07
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
          inc(i);
          if i>n then i:=1;
          if a[i]>0 then inc(s);
          if s=j then
          begin
               write(a[i],' ');
               a[i]:=-1;
               inc(x);
               inc(j);
               s:=0;
          end;
     end;
close(output);
end.