记录编号 3445 评测结果 AAAAAAAAAA
题目名称 [NOIP 2006]明明的随机数 最终得分 100
用户昵称 Gravatarname:弓虽 是否通过 通过
代码语言 Pascal 运行时间 0.016 s
提交时间 2008-10-07 00:27:48 内存使用 0.11 MiB
显示代码纯文本
program random(input,output);
 var
  i,j,k,n,ans:longint;
  f1,f2:text;
   a:array[1..101] of longint;
   b:array [1..101] of boolean;

   procedure quick(i,j:longint);
    var
     x,head,tail,temp:longint;
    begin
     head:=i;
     tail:=j;
     x:=a[(head+tail) div 2];
     repeat
      while a[head]<x do inc(head);
      while a[tail]>x do dec(tail);
       if head<=tail then
        begin
         temp:=a[head];
         a[head]:=a[tail];
         a[tail]:=temp;
         inc(head);
         dec(tail);
        end ;
          until head>tail;
    if head<j then quick(head,j);
    if tail>i then quick(i,tail);
  end;
begin
 assign(f1,'random.in');
 assign(f2,'random.out');
 reset(f1);
 rewrite(f2);
 readln(f1,n);
  for i:=1 to n do begin
   read(f1,a[i]);
   b[i]:=true;
   end;
   quick(1,n);
   ans:=n;
    for i:=1 to n-1 do
     if a[i]=a[i+1] then begin
      b[i]:=false; ans:=ans-1;
      end;
      writeln(f2,ans);
   for i:=1 to n do
    if b[i]=true then
     write(f2,a[i],' ');
     close(f1);
     close(f2);
    end.