记录编号 49444 评测结果 AAAAA
题目名称 三只小猪 最终得分 100
用户昵称 Gravatarlimitation 是否通过 通过
代码语言 Pascal 运行时间 0.038 s
提交时间 2012-11-08 08:12:06 内存使用 4.02 MiB
显示代码纯文本
program p1255;
 type arr=array[1..100]of longint;
 var f:array[1..100,0..100]of arr;
     i,j,loop,n,m,t,l:longint;
  function time(p:arr;o:longint):arr;
   var c:arr;
       i:longint;
    begin
     fillchar(c,sizeof(c),0);
     for i:=1 to 99 do
      begin
       c[i]:=c[i]+p[i]*o;
       c[i+1]:=c[i] div 10;
       c[i]:=c[i] mod 10;
      end;
     exit(c);
    end;
  function add(p,o:arr):arr;
   var c:arr;
       i:longint;
    begin
     fillchar(c,sizeof(c),0);
     for i:=1 to 99 do
      begin
       c[i]:=c[i]+p[i]+o[i];
       c[i+1]:=c[i] div 10;
       c[i]:=c[i] mod 10;
      end;
     exit(c);
    end;
  begin
   assign(input,'piggy.in');
   reset(input);
   assign(output,'piggy.pas');
   rewrite(output);
   close(output);
   assign(output,'piggy.out');
   rewrite(output);
   for i:=1 to 60 do
    begin
     f[i,i][1]:=1;
     f[i,1][1]:=1;
     f[i,0][1]:=0;
    end;
   for i:=2 to 60 do
    for j:=1 to 60 do
     f[i,j]:=add(time(f[i-1,j],j),f[i-1,j-1]);
   read(t);
   for loop:=1 to t do
    begin
     read(n,m);
     l:=100;
     while (f[n,m][l]=0)and(l>1) do dec(l);
     for i:=l downto 1 do
      write(f[n,m][i]);
    end;
   close(input);
   close(output);
  end.