比赛 20111111 评测结果 AWWWWWWWWA
题目名称 吉祥数 最终得分 20
用户昵称 11111111 运行时间 0.004 s
代码语言 Pascal 内存使用 0.26 MiB
提交时间 2011-11-11 10:49:29
显示代码纯文本
program aa;
var
a,b,c,d,e,f,i,j,n,m,g,max:longint;
l:array[1..2000]of longint;
wei:array[1..2000]of longint;
t:array[1..2000,1..10]of longint;
sum:array[1..2000]of longint;
f1,f2:text;
//*************************************
procedure du;
begin
 readln(f1,n);i:=0;
 while not eof(f1) do
 begin
  inc(i);
  read(f1,l[i]);
 end;
 m:=i;
end;
//*************************************
procedure qushu;
begin
 for i:=1 to m do
 begin
  a:=l[i];
  wei[i]:=0;
  while a>0 do
  begin
   inc(wei[i]);
   t[i,wei[i]]:=a mod 10;
   a:=a div 10;
  end;
 end;
end;
//*************************************
procedure try(g:longint);
var
i,j,k:longint;
begin
 for i:=1 to m do
 begin

  for j:=1 to wei[i] do
  begin
   max:=1;
   for k:=1 to g+1 do
   max:=max*t[i,j];
   sum[i]:=sum[i]+max;
  end;
  for j:=1 to m do
  if sum[i]=l[j] then
  begin
   for k:=j to m-1 do
    l[k]:=l[k+1];
   dec(m);
  end;
 end;
end;
//*************************************
procedure Sort(t, r: longint);
var
  i, j, x, y: longint;
begin
  i := t; j := r; x := l[(t+r) DIV 2];
  repeat
    while l[i] < x do i := i + 1;
    while x < l[j] do j := j - 1;
    if i <= j then
    begin
      y := l[i]; l[i] := l[j]; l[j] := y;
      i := i + 1; j := j - 1;
    end;
  until i > j;
  if t < j then Sort(t, j);
  if i < r then Sort(i, r);
end;
//*************************************
begin
 assign(f1,'ghillie.in');
 assign(f2,'ghillie.out');
 reset(f1);
 rewrite(f2);
 du;
 qushu;
 if n>=1 then try(1);
 if n>=2 then try(2);
 if n>=3 then try(3);
 if n>=4 then try(4);
 if n>=5 then try(5);
 if n>=6 then try(6);
 if n>=7 then try(7);
 sort(1,m);
 for i:=1 to m do
 write(f2,l[i],' ');
 close(f1);close(f2);
end.