记录编号 |
19062 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2009]细胞分裂 |
最终得分 |
100 |
用户昵称 |
Des. |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.167 s |
提交时间 |
2010-09-28 12:52:59 |
内存使用 |
0.72 MiB |
显示代码纯文本
program cell;
var a,b,p:array[0..50000]of longint;
mid,ced:array[0..5000]of longint;
t,k,m,n,i,j,x,y,mini,zz,m1,m2:longint;
procedure prime;
var t,k:longint;
begin
p[1]:=2;
p[2]:=3;
p[3]:=5;
j:=3;
for t:=5 to 50000 do
if (t mod 2>0)and(t mod 3>0)and(t mod 5>0)and(b[t]=0) then
begin
inc(j);
p[j]:=t;
for k:=1 to 50000 div t do
b[t*k]:=1;
end;
end;
procedure fenjie1(i:longint);
var t,k,o:longint;
begin
k:=0;
o:=i;
repeat
inc(k);
if o mod p[k]=0 then
repeat
o:=o div p[k];
inc(mid[k]);
until o mod p[k]<>0;
until o=1;
mid[0]:=k;
end;
procedure fenjie2(i:longint);
var t,k,o:longint;
begin
fillchar(ced,sizeof(ced),0);
k:=0;
o:=i;
repeat
inc(k);
if o mod p[k]=0 then
repeat
o:=o div p[k];
inc(ced[k]);
until o mod p[k]<>0;
until (o=1)or(k>mid[0]);
ced[0]:=k;
end;
function min(x,y:longint):longint;
begin
if x>y then min:=y else min:=x;
end;
function max(x,y:longint):longint;
begin
if x>y then max:=x else max:=y;
end;
function gcd(x,y:longint):longint;
var t,k,a,b:longint;
begin
t:=max(x,y);
k:=min(x,y);
repeat
i:=k;
a:=t mod k;
b:=t div k;
t:=max(a,b);
k:=min(a,b);
until a=0;
gcd:=i;
end;
procedure ppit;
var t,k,x,y:longint;
begin
x:=0;
if ced[0]>=mid[0] then
begin
for t:=1 to mid[0] do
if mid[t]>0 then
begin
if ced[t]=0 then exit;
if (mid[t]div ced[t]>x)and(mid[t]mod ced[t]=0) then
x:=mid[t]div ced[t]
else if(mid[t]div ced[t]+1>x)and(mid[t]mod ced[t]>0) then
x:=mid[t]div ced[t]+1
end;
zz:=x;
end;
end;
begin
assign(input,'cell.in');
reset(input);
assign(output,'cell.out');
rewrite(output);
readln(n);
readln(m1,m2);
if (m1=1)and(m2=1) then
begin
writeln(0);
close(output);
halt;
end;
for t:=1 to n do
read(a[t]);
prime;
fenjie1(m1);
for t:=1 to mid[0] do
mid[t]:=mid[t]*m2;
for t:=1 to n do
begin
fenjie2(a[t]);
ppit;
if (zz<mini)or(mini=0) then mini:=zz;
end;
if mini=0 then
mini:=-1;
writeln(mini);
close(output);
end.