比赛 20111111 评测结果 EEEEEEEEEE
题目名称 吉祥数 最终得分 0
用户昵称 reamb 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2011-11-11 11:00:35
显示代码纯文本
program ghillie;
var
  n,t,i,j,k,ww,w,q,p:longint;
  s,ans,d:int64;
  bz:array[1..200]of boolean;
  a:array[1..200]of longint;
  team:array[1..200]of longint;
procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]<x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;
function make(x,y:longint):int64;
begin
  ans:=0;
  w:=x;
  repeat
    p:=w mod 10;
    w:=w div 10;
    s:=p;
    for j:=1 to y-1 do
      s:=s*p;
    ans:=ans+s
  until w=0;
  exit(ans)
end;
begin
  assign (input,'ghillie.in');
  reset (input);
  assign (output,'ghillie.out');
  rewrite (output);
    readln (n);
    repeat
      inc(t);
      read (a[t])
    until eoln;
    sort(1,t);
    for i:=1 to t do
      bz[i]:=true;
    for q:=1 to n do
    begin
      ww:=0;
      for i:=1 to t do
        if bz[i] then
        begin
          d:=make(a[i],q+1);
          if d<255 then
          begin
            inc(ww);
            team[ww]:=d
          end
        end;
      for i:=1 to ww do
        for j:=1 to t do
          if a[j]=team[i] then
            bz[j]:=false
    end;
    for i:=1 to t do
      if bz[i] then
        write (a[i],' ');
  close (input);
  close (output)
end.