比赛 20100927 评测结果 WWWWWWWWWW
题目名称 细胞分裂 最终得分 0
用户昵称 kaaala 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-09-27 19:38:56
显示代码纯文本
program ex(input,output);
type
 s=record
  fl:boolean;
  si:word;
 end;
var
 n:integer;
 m1,m2:integer;
 m:word;
 i,j,k:integer;
 f:boolean;
 max,max1:word;
 z:integer;
 a:array[1..10000]of s;
procedure try(q:word;w:word);
begin
 if q mod 2=0 then
  a[w].fl:=true
 else
  a[w].fl:=false;
end;
procedure try1(e:word);
begin
 if e mod 2=0 then
  f:=true
 else
  f:=false;
end;
begin
 assign(input,'cell.in');
 assign(output,'cell.out');
 reset(input);
 rewrite(output);
 readln(n);
 readln(m1,m2);
 for i:=1 to n do
  read(a[i].si);
 m:=0;
 max:=maxint;
 if m2=1 then
  m:=m1
 else
 for i:=1 to m2 do
  m:=m1*m1+m;
 try1(m);
 for i:=1 to n do
  try(a[i].si,i);
 for i:=1 to n do
  if a[i].fl=f then
   if (m mod a[i].si=0)and(a[i].si mod m<>0) then
   begin
    max1:=m div a[i].si;
    if max1<=max then
     max:=max1
   end
   else
   if (m mod a[i].si<>0)and(a[i].si mod m<>0) then
   begin
    for j:=1 to maxint do
    begin
     z:=0;
     for k:=1 to j do
      z:=z+a[i].si*a[i].si;
      if (m mod z=0)or(z mod m=0) then
      begin
       max1:=j;
       break;
      end;
      if (max1<=max)and(max1<>0) then
       max:=max1;
      break;
     end;
   end
   else
   if (a[i].si mod m=0)and(m mod a[i].si<>0) then
   begin
    max1:=1;
    if max1<=max then
     max:=max1;
   end
   else
   if (m mod a[i].si=0)and(a[i].si mod m=0) then
    max:=0;
 if max=maxint then
  writeln('-1')
 else
  writeln(max);
 close(input);
 close(output);
end.