比赛 暑假培训六 评测结果 AAAAAAAAAA
题目名称 明明的随机数 最终得分 100
用户昵称 Oo湼鞶oO 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-23 09:20:03
显示代码纯文本
{*******************************************}
{* Program Name: Random                    *}
{* Input File: random.in                   *}
{* Output File: random.out                 *}
{* Date: 2008.7.23                         *}
{* Programmer: Peng Bo                     *}
{*******************************************}
program random;
type
  s1=Array[1..100]of word;
  s2=array[1..1000]of boolean;
var
  s:s1;
  c:s2;
  n,m:byte;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure input;
var
  f:text;
  t:word;
  i:byte;
begin
  assign(f,'random.in');
  reset(f);
  readln(f,n);
  for i:=1 to n do
  begin
    read(f,t);
    c[t]:=true;
  end;
  close(f);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure output;
var
  f:text;
  i:byte;
begin
  assign(f,'random.out');
  rewrite(f);
  writeln(f,m);
  for i:=1 to m do
    write(f,s[i],' ');
  close(f);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure dr;
var
  i:word;
begin
  for i:=1 to 1000 do
    if c[i]
    then
    begin
      inc(m);
      s[m]:=i;
    end;
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure px(l,r:byte);
var
  i,j:byte;
  x,t:word;
begin
  i:=l;
  j:=r;
  x:=s[(l+r)div 2];
  repeat
    while s[i]<x do
      inc(i);
    while x<s[j] do
      dec(j);
    if i<=j
    then
    begin
      t:=s[i];
      s[i]:=s[j];
      s[j]:=t;
      inc(i);
      dec(j);
    end;
  until i>j;
  if l<j
  then
    px(l,j);
  if i<r
  then
    px(i,r);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
begin
  m:=0;
  input;
  dr;
  px(1,m);
  output;
end.
{End.}