比赛 |
20111111 |
评测结果 |
EEEEEEEEEE |
题目名称 |
吉祥数 |
最终得分 |
0 |
用户昵称 |
lizhe |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2011-11-11 08:49:51 |
显示代码纯文本
program ghillie;
var
i,j,n,u,t,m:longint;
sum:int64;
a,b:array[1..300]of longint;
s,s0:string;
k:integer;
procedure swap(var a0,b0:longint);
var
c0:longint;
begin
c0:=a0;
a0:=b0;
b0:=c0
end;
procedure sort(l,r:longint);
var
i,j,x: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 i<=j then
begin
swap(a[i],a[j]);
inc(i);
dec(j);
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end;
procedure init;
begin
assign(input,'ghillie.in');
reset(input);
assign(output,'ghillie.out');
rewrite(output);
readln(n);
t:=0;
repeat
inc(t);
read(a[t])
until eof;
sort(1,t)
end;
function suan(x:longint):longint;
var
l,q:longint;
begin
q:=1;
for l:=1 to x do
q:=q*m;
suan:=q
end;
procedure main;
begin
for i:=1 to n do
for j:=1 to t do
if t<>-1 then
begin
str(a[j],s);
sum:=0;
while s<>'' do
begin
s0:=copy(s,1,1);
delete(s,1,1);
val(s0,m,k);
sum:=sum+suan(i+1)
end;
for u:=1 to t do
if a[u]=sum then
a[u]:=-1
end;
end;
procedure print;
begin
n:=0;
for i:=1 to t do
if a[i]<>-1 then
begin
inc(n);
b[n]:=a[i]
end;
for i:=1 to n-1 do
write(b[i],' ');
writeln(b[n]);
close(input);
close(output)
end;
begin
init;
main;
print
end.