记录编号 |
3230 |
评测结果 |
AAAAAAAAAA |
题目名称 |
乘法问题 |
最终得分 |
100 |
用户昵称 |
苏轼 |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.057 s |
提交时间 |
2008-10-05 17:10:55 |
内存使用 |
0.61 MiB |
显示代码纯文本
program cch(input,output);
var
f:array[1..40,0..10] of string;
i,j,n,m,k,code:integer;
s:string;
num:array[1..40,1..40] of string;
function max(x,y:string):string;
begin
if length(x)>length(y) then exit(x);
if length(x)<length(y) then exit(y);
if x>y then exit(x)
else exit(y);
end;
function mul(s1,s2:string):string;
var
l1,l2,i,j,l:integer;
a,b,c:array[1..200] of integer;
s3:string;
begin
l1:=length(s1); l2:=length(s2);
for i:=1 to l1 do a[i]:=ord(s1[l1-i+1])-48;
for i:=1 to l2 do b[i]:=ord(s2[l2-i+1])-48;
l:=l1+l2+1;
for i:=1 to l do c[i]:=0;
for i:=1 to l1 do
for j:=1 to l2 do
c[i+j]:=c[i+j]+a[i]*b[j];
for i:=2 to l1+l2 do
begin
c[i+1]:=c[i+1]+c[i] div 10;
c[i]:=c[i] mod 10;
end;
while (l>2)and(c[l]=0) do dec(l);
s3:='';
for i:=2 to l do s3:=s3+chr(c[l-i+2]+48);
mul:=s3;
end;
begin
assign(input,'chf.in');
assign(output,'chf.out');
reset(input);
rewrite(output);
readln(n,m);
readln(s);
for i:=1 to length(s) do
for j:=i to length(s) do
num[i,j]:=copy(s,i,j-i+1);
for i:=1 to n do f[i,0]:=num[1,i];
for i:=1 to m do
for j:=i+1 to n do
begin
f[j,i]:='0';
for k:=i to j do
f[j,i]:=max(f[j,i],mul(f[k,i-1],num[k+1,j]));
end;
write(f[n,m]);
close(input);
close(output);
end.