记录编号 40527 评测结果 AAAAAAAAAAAAAA
题目名称 [暑假培训2012] 残酷的数学老师 最终得分 100
用户昵称 GravatarRT 是否通过 通过
代码语言 Pascal 运行时间 0.685 s
提交时间 2012-07-18 11:43:13 内存使用 0.34 MiB
显示代码纯文本
program p3;
var
s,m,ans:array[1..15010] of longint;
a,b,c,d,n,p,ansl,sl,ml:longint;
begin
assign(input,'cruel1.in');
reset(input);
assign(output,'cruel1.out');
rewrite(output);
 
 
 
read(n,p);
ans[1]:=1;
 
a:=0;
while n>0 do
begin
inc(a);
s[a]:=n mod 10;
n:=n div 10;
end;
 
repeat
fillchar(m,sizeof(m),0);
if p mod 2=1 then
begin
ansl:=15000;sl:=15000;
while (ans[ansl]=0) and (ansl<>1)  do dec(ansl);
while (s[sl]=0) and  (sl<>1) do dec(sl);
for a:=1 to ansl do
for b:=1 to sl do
m[a+b-1]:=m[a+b-1]+ans[a]*s[b];
ml:=15000;
while (m[ml]=0) and (ml<>1) do dec(ml);
for a:=1 to ml do
begin m[a+1]:=m[a+1]+m[a] div 10;m[a]:=m[a] mod 10;end;
for a:=1 to ml+1 do
ans[a]:=m[a];
end;
p:=p div 2;
fillchar(m,sizeof(m),0);
sl:=15000;
while (s[sl]=0) and  (sl<>1) do dec(sl);
for a:=1 to sl do
for b:=1 to sl do
m[a+b-1]:=m[a+b-1]+s[a]*s[b];
ml:=15000;
while (m[ml]=0) and (ml<>1) do dec(ml);
for a:=1 to ml do
begin m[a+1]:=m[a+1]+m[a] div 10;m[a]:=m[a] mod 10;end;
for a:=1 to ml+1 do
s[a]:=m[a];
 
until p=0;
ansl:=15000;
while (ans[ansl]=0) and (ansl<>1) do dec(ansl);
b:=0;
for a:=ansl downto 1 do
begin
inc(b);
if b mod 70 = 0 then writeln(ans[a]) else write(ans[a]);end;
close(input);
close(output);
end.