记录编号 4861 评测结果 AAAAAAAAAA
题目名称 乘法问题 最终得分 100
用户昵称 GravatarReimBurSe. 是否通过 通过
代码语言 Pascal 运行时间 0.021 s
提交时间 2008-10-22 21:08:17 内存使用 0.12 MiB
显示代码纯文本
Program chf;

Type
sc=array [1..30,0..30] of int64;
sc1=array [1..30,1..30] of int64;

Var
p,i,j,n,k,code:integer;
temp:int64;
s:sc;
a:sc1;
y,f:string;

Begin
assign(input,'chf.in');
assign(output,'chf.out');
reset(input);
rewrite(output);
readln(n,k);
readln(y);
for i:=1 to n do begin
 for j:=1 to n do begin
  s[i,j]:=0; a[i,j]:=1;
 end;
end;
for i:=1 to n do s[i,0]:=0;

for i:=1 to n do begin
 for j:=1 to n-i+1 do begin
  f:=copy(y,i,j);
  val(f,a[i,i+j-1],code);
 end;
end;
for i:=1 to n do s[i,0]:=a[1,i];

for j:=1 to k do begin
 for i:=j+1 to n do begin
  temp:=0;
  for p:=1 to i-j do
   if temp<s[i-p,j-1]*a[i-p+1,i] then
    temp:=s[i-p,j-1]*a[i-p+1,i];
  s[i,j]:=temp;
 end;
end;

writeln(s[n,k]);
close(input);
close(output);
End.