比赛 20130725暑期B班1测 评测结果 TTTTTTTTTTTTTT
题目名称 残酷的数学老师 最终得分 0
用户昵称 o_o 运行时间 14.000 s
代码语言 Pascal 内存使用 0.54 MiB
提交时间 2012-07-18 10:21:53
显示代码纯文本
var
  n,m,w:longint;
  i,j:longint;
  out:array[1..50000] of longint;
  sta:array[1..50000] of longint;
  procedure solve(n:longint);
    begin
      if n=0 then
        exit;
      solve(n div m);

      for i:=1 to 15000 do
        for j:=1 to 15000 do
          if n mod m=0
            then
              sta[i+j-1]:=sta[i+j-1]+out[i]*out[j]
            else
              sta[i+j-1]:=sta[i+j-1]+out[i]*out[j]*m;
      for i:=1 to 15000 do
        begin
          out[i]:=sta[i] mod 10;
          sta[i+1]:=sta[i+1]+sta[i] div 10;
        end;
      for i:=1 to 15000 do   sta[i]:=0;

  end;
begin
assign(input,'cruel1.in');
assign(output,'cruel1.out');
reset(input);
rewrite(output);
  readln(m,n);

  out[1]:=1;
  solve(n);
  for i:=15000 downto 1 do
    begin
    if out[i]<>0 then
      begin
      write(out[i]);
      w:=w+1;
      end;
      if (w mod 70=1)and(w<>1) then  writeln;
    end;
 close(input);
 close(output);
end.