记录编号 1097 评测结果 AAAAAAAAAA
题目名称 [NOIP 2006]明明的随机数 最终得分 100
用户昵称 GravatarHamster 是否通过 通过
代码语言 Pascal 运行时间 0.005 s
提交时间 2008-07-24 09:05:00 内存使用 0.00 MiB
显示代码纯文本
program random;
var
  a:array[1..102] of integer;
  n,i,j,q,s:longint;
  fin,fout:text;

procedure init;
begin
  readln(fin,n);
  for i:=1 to n do read(fin,a[i]);
end;

procedure paixu;
var
  temp:integer;
begin
  for i:=1 to n-1 do
    for j:=n downto i+1 do
      if a[i]>a[j] then
      begin
        temp:=a[i];
        a[i]:=a[j];
        a[j]:=temp;
      end;
end;

procedure print;
begin
  q:=0;
  for i:=1 to n do
  begin
    if (i=1) then
    begin
      s:=a[i];
      inc(q)
    end
    else
      if (i<>1) and (a[i]<>s) then
      begin
        inc(q);
        s:=a[i];
      end
      else
      begin
        s:=a[i];
        a[i]:=0;
      end;
  end;
  writeln(fout,q);
  for i:=1 to n-1 do
    if a[i]<>0 then write(fout,a[i],' ');
  write(fout,a[n]);
end;

begin
  assign(fin,'random.in');
  reset(fin);
  assign(fout,'random.out');
  rewrite(fout);

  init;
  paixu;
  print;

  close(fin);
  close(fout);
end.