比赛 |
20120619 |
评测结果 |
AEWEEWAWEA |
题目名称 |
隐藏的信息 |
最终得分 |
30 |
用户昵称 |
wo shi 刘畅 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2012-06-19 19:45:08 |
显示代码纯文本
var
ss:string;
x,y,s,n,i,m,d:longint;
a,p:array[0..1000]of longint;
v:array[0..10000]of boolean;
function gcd(x,y:longint):longint;
begin
if y=0 then exit(x);
gcd:=gcd(y,x mod y);
end;
procedure sort(l,r:longint);
var
i,j,x,y:longint;
begin
i:=l;
j:=r;
x:=a[(i+j) div 2];
repeat
while a[i]<x do inc(i);
while x<a[j] do dec(j);
if i<=j then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
dec(j);
end;
until i>j;
if i<r then sort(i,r);
if l<j then sort(l,j);
end;
procedure go(k:longint);
var
i:longint;
begin
if k>n then
begin
if s mod d=0 then writeln(s);
exit;
end;
for i:=1 to n do
if not v[i] then
begin
v[i]:=true;
s:=s*10+a[i];
go(k+1);
s:=(s-a[i]) div 10;
v[i]:=false;
end;
end;
begin
assign(input,'lcsa.in'); reset(input);
assign(output,'lcsa.out'); rewrite(output);
readln(ss);
n:=length(ss);
for i:=1 to n do a[i]:=ord(ss[i])-48;
sort(1,n);
readln(x,y);
m:=y-x+1;
for i:=1 to m do p[i]:=x+i-1;
d:=p[1]*p[2] div gcd(p[1],p[2]);
for i:=2 to m do
d:=d*p[2] div gcd(d,p[2]);
go(1);
close(input);
close(output);
end.