1 条题解

  • 0
    @ 2021-6-15 1:39:41

    Pascal :

    program cell;
    var
      i,n,m1,m2,t,p,q,time,ans:longint;
      a:array[1..200,1..2]of longint;
    
    procedure fj(m:longint);
    var
      s,i:longint;
    begin
      s:=2;
      while m>1 do
      begin
        if m mod s=0 then
        begin
          inc(p);
          a[p,1]:=s;
        end;
        while m mod s=0 do
        begin
          m:=m div s;
          inc(a[p,2]);
        end;
        inc(s);
      end;
      for i:=1 to p do
        a[i,2]:=a[i,2]*m2;
    end;
    
    procedure work(t:longint);
    var
      i,now:longint;
    begin
      time:=-1;
      for i:=1 to p do
      begin
        q:=0;
        if t mod a[i,1]<>0 then
        begin
          time:=maxlongint;
          exit;
        end;
        while t mod a[i,1]=0 do
        begin
          t:=t div a[i,1];
          inc(q);
        end;
        if q>=a[i,2] then now:=0
          else if a[i,2]mod q=0 then now:=a[i,2] div q
            else now:=a[i,2] div q+1;
        if now>time then time:=now;
      end;
    end;
    
    begin
      readln(n);
      readln(m1,m2);
      if m1=1 then
      begin
        writeln(0);
        exit;
      end;
      ans:=maxlongint;
      fj(m1);
      for i:=1 to n do
      begin
        read(t);
        work(t);
        if time<ans then ans:=time;
      end;
      if ans=maxlongint then writeln(-1)
        else writeln(ans);
    end.
    
    
    • 1

    信息

    ID
    270
    时间
    1000ms
    内存
    125MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者