记录编号 78359 评测结果 AAAAAAAAAA
题目名称 方程 最终得分 100
用户昵称 Gravatar, 是否通过 通过
代码语言 Pascal 运行时间 1.425 s
提交时间 2013-11-03 20:33:14 内存使用 0.64 MiB
显示代码纯文本
program gmy(input,output);
var
 k,i,j,l,ll,ii:longint;
 x,y,z:int64;
 a:array[0..1,0..1000,0..30]of int64;
function max(a,b:longint):longint;
begin
 if a>=b then exit(a)
         else exit(b);
end;
begin
 assign(input,'equationz.in');
 reset(input);
 assign(output,'equationz.out');
 rewrite(output);
 readln(k,x);
 y:=1;
 z:=x mod 1000;
 repeat
   if x mod 2=1 then y:=(y*z) mod 1000;
   z:=z*z mod 1000;
   x:=x div 2;
 until x=0;
 a[1,1,0]:=1;
 a[1,1,1]:=1;
 i:=1;
 repeat
   i:=i+1;
   if i=238 then begin
   i:=i+1;
   i:=i-1;
   end;
   ii:=i mod 2;
   for j:=1 to i do
     begin
      if j mod 116=0 then begin
      i:=i+1;
      i:=i-1;
      end;
      ll:=max(a[1-ii,j,0],a[1-ii,j-1,0]);
      a[ii,j,0]:=ll;
      for l:=1 to ll do
        a[ii,j,l]:=a[1-ii,j-1,l]+a[1-ii,j,l];
      ll:=0;
      repeat
        ll:=ll+1;
        if a[ii,j,ll]>9999999 then begin
                             a[ii,j,ll+1]:=a[ii,j,ll+1]+a[ii,j,ll] div 10000000;
                             a[ii,j,ll]:=a[ii,j,ll] mod 10000000;
                             if ll=a[ii,j,0] then a[ii,j,0]:=a[ii,j,0]+1;
                            end;
      until ll=a[ii,j,0];
     end;
 until i=y;
 l:=y mod 2;
 for i:=a[l,k,0] downto 1 do
   begin
    if (i<>a[l,k,0]) then begin
                           if (a[l,k,i]>=1) and (a[l,k,i]<10)
                           then write('000000',a[l,k,i]);
                           if (a[l,k,i]>=10) and (a[l,k,i]<100)
                           then write('00000',a[l,k,i]);
                           if (a[l,k,i]>=100) and (a[l,k,i]<1000)
                           then write('0000',a[l,k,i]);
                           if (a[l,k,i]>=1000) and (a[l,k,i]<10000)
                           then write('000',a[l,k,i]);
                           if (a[l,k,i]>=10000) and (a[l,k,i]<100000)
                           then write('00',a[l,k,i]);
                           if (a[l,k,i]>=100000) and (a[l,k,i]<1000000)
                           then write('0',a[l,k,i]);
                           if (a[l,k,i]>=1000000) and (a[l,k,i]<10000000)
                           then write(a[l,k,i]);
                          end
                     else write(a[l,k,i]);
   end;
 close(input);
 close(output);
end.