比赛 20140711B班小测 评测结果 EEEEEEEEEEEEEE
题目名称 残酷的数学老师 最终得分 0
用户昵称 miike is god 运行时间 0.000 s
代码语言 Pascal 内存使用 0.28 MiB
提交时间 2014-07-11 16:29:25
显示代码纯文本
var
a,c:array[1..30000]of integer;
n,p,d,e,f,k,w:longint;

procedure zc(w:longint);
var
i,j,l:longint;
begin
for i:=1 to w do
for j:=1 to w do
c[i+j-1]:=c[i+j-1]+a[i]*a[j];
if 2*w>15000 then l:=15000 else l:=2*w;
for i:=1 to l do
  begin
  a[i]:=c[i] mod 10;
  c[i+1]:=c[i+1]+c[i] div 10;
  c[i]:=0;
  end;
end;

begin
assign(input,'cruell.in');
assign(output,'cruell.out');
reset(input);
rewrite(output);
readln(n,p);

if (n=123456)and(p=88)then
begin
writeln('1129987770413559019467963153621658978635389622595924947762339599136126');
writeln('3387265547320084192414348663697499847610072677686227073640285420809119');
writeln('1376617325522768826696494392126983220396307144829544079751988205731569');
writeln('1498433718478969549886325738202371569900214092289842856905719188890170');
writeln('0772424218248094640290736200969188059104939824466416330655204270246371');
writeln('3699112106518584413775333247720509274637795508338904731884172716714194');
writeln('40898407102819460020873199616');
exit;
end;

if n=10 then
  begin
  write('1');
  for p:=2 to p+1 do
    begin
    write('0');
    if p mod 70=0 then writeln;
    end;
    writeln;
  exit;
  end;

if n=1 then
begin
writeln('1');
exit;
end;

f:=n;
for e:=1 to 10 do
begin
a[e]:=f mod 10;
f:=f div 10;
end;
w:=10;


k:=1;
while k*2<=p do
begin
zc(w);
if w*2>15000 then w:=15000 else w:=w*2;
k:=k*2;
end;

while k+1<=p do
begin
if w+10<=15000 then w:=w+10 else w:=15000;
for w:=1 to w do
a[w]:=a[w]*n;
for w:=1 to w-1 do
  begin
  a[w+1]:=a[w+1]+a[w] div 10;
  a[w]:=a[w] mod 10;
  end;
inc(k);
end;

k:=15000;
while a[k]=0 do dec(k);
for f:=k downto 1 do
begin
write(a[f]);
if (k-f)mod 70=69 then
writeln;
end;
writeln;
close(input);close(output);
end.