- 乘积最大
- 2016-11-12 16:24:53 @
var
n,k,i,j,max,t,tt:longint;
opt:array[0..41,0..7]of longint;
c:char;
num:array[0..41]of 0..9;
function
make(l,r:longint):longint;
var
i:longint;
begin
make:=0;
for i:=l to r do
make:=make*10+num[i];
end;
begin
readln(n,k);
for i:=1 to n do
begin
read(c);
num[i]:=ord(c)-48;
end;
for i:=1 to n do
for j:=1 to i do
opt[i,0]:=opt[i,0]*10+num[j];
for i:=1 to n do
for j:=1 to k do
begin
max:=0;
for t:=j to i-1 do
begin
tt:=opt[t,j-1]*make(t+1,i);
if max<tt then max:=tt;
end;
opt[i,j]:=max;
end;
writeln(opt[n,k]);
end.
0 条评论
目前还没有评论...