比赛 暑假培训七 评测结果 AAWAAAEEEE
题目名称 乘法问题 最终得分 50
用户昵称 E.M.B.E.R 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-24 15:54:30
显示代码纯文本
program EmberAsh;
var
  f,g:array[0..51,0..51]of longint;
  n,k,i,j,p,t1:longint;
  ss:integer;
  s,s1:string;
  fin,fout:text;

BEGIN
assign(fin,'chf.in');
assign(fout,'chf.out');
reset(fin);rewrite(fout);
readln(fin,n,k);
readln(fin,s);
for i:=1 to n do
  for j:=1 to n do
    begin
    s1:=copy(s,i,j-i+1);
    val(s1,g[i,j],ss);
    end;
for i:=1 to n do
  f[i,0]:=g[1,i];
for i:=1 to n do
  for j:=1 to i-1 do
    begin
    t1:=f[j,0]*g[j+1,i];
    if t1>f[i,1]
    then f[i,1]:=t1;
    end;
for i:=2 to n do
  for j:=1 to k do
  begin
  for p:=i downto 1 do
    begin
      if p<=j-1 then break;
      t1:=f[p,j-1]*g[p+1,i];
      if t1>f[i,j]
      then f[i,j]:=t1;
    end;
  end;
writeln(fout,f[n,k]);
close(fin);close(fout);
END.