记录编号 64998 评测结果 AAAAAAAAAAAATA
题目名称 [暑假培训2012] 残酷的数学老师 最终得分 92
用户昵称 Gravatarhjh 是否通过 未通过
代码语言 Pascal 运行时间 2.180 s
提交时间 2013-07-25 12:24:55 内存使用 1.49 MiB
显示代码纯文本
type
arr=array[1..15100]of longint;

var
m,v:arr;
z:array[0..20]of arr;
x:array[0..20]of longint;
n1,p,i,k,j:longint;


procedure cc(a:arr);
var l,q,w,n:longint;
begin
l:=15000;
while a[l]=0 do dec(l);
for q:=1 to l do
    for w:=1 to l do
    begin
    n:=q+w-1;
    z[i+1,n]:=z[i+1,n]+a[q]*a[w];
    z[i+1,n+1]:=z[i+1,n+1]+z[i+1,n] div 10;
    z[i+1,n]:=z[i+1,n] mod 10;
    end;
end;
procedure ccc(a,b:arr);
var l1,l2,q,w,n:longint;
begin
l1:=15000;l2:=15000;
while a[l1]=0 do dec(l1);
while b[l2]=0 do dec(l2);
for q:=1 to l1 do
    for w:=1 to l2 do
    begin
    n:=q+w-1;
    v[n]:=v[n]+a[q]*b[w];
    v[n+1]:=v[n+1]+v[n] div 10;
    v[n]:=v[n] mod 10;
    end;
end;


begin
assign(input,'cruel1.in');
reset(input);
assign(output,'cruel1.out');
rewrite(output);

read(n1,p);
for i:=1 to 10 do
    begin
    z[0,i]:=n1 mod 10;
    n1:=n1 div 10;
    end;

for i:=0 to 16 do begin x[i]:=p mod 2; p:=p div 2; if x[i]=1 then k:=i; end;

for i:=0 to k do cc(z[i]);

m[1]:=1;
for  i:=0 to k do if x[i]=1 then begin
                                fillchar(v,sizeof(v),0);
                                ccc(m,z[i]);
                                m:=v;
                                end;
i:=15000;
j:=0;
while v[i]=0 do dec(i);
for k:=i downto 1 do
    begin
    inc(j);
    write(v[k]);
    if j=70 then begin writeln; j:=0; end;
    end;







close(input);
close(output);
end.