测试结果1: 通过本测试点|有效耗时172ms
测试结果2: 测试结果错误.错误结果为:5166000 正确结果应为:516600
测试结果3: 通过本测试点|有效耗时47ms
测试结果4: 通过本测试点|有效耗时62ms
测试结果5: 通过本测试点|有效耗时63ms
测试结果6: 通过本测试点|有效耗时63ms
测试结果7: 通过本测试点|有效耗时62ms
测试结果8: 输出过长|用户输出数据超过标准输出两倍[标准输出1位|选手输出11位]
这是我的程序:
program vijos_1347;
const
maxn=255;
type
sys_int=longint;
numtype=array [0..maxn]of integer;
var
n,k,m:sys_int;
cin:string;
num:numtype;
f:array [0..maxn]of numtype;
procedure init;
begin
fillchar(f,sizeof(f),0);
cin:=’’;
//init
readln(n,k);
m:=k+1;
readln(cin);
end;
function mul(orig,st,en:sys_int):numtype;
var
i,j,w:sys_int;
lin:numtype;
begin
fillchar(num,sizeof(num),0);
fillchar(lin,sizeof(lin),0);//init
j:=0;
for i:=en downto st do
begin inc(j);lin[j]:=ord(cin[i])-48;end;
lin[0]:=en-st+1;
while (lin[lin[0]]=0)and(lin[0]>=1) do dec(lin[0]);
num[0]:=lin[0]+f[orig][0];
for i:=num[0]+1 downto f[orig][0]+1 do
f[orig][i]:=0;
for i:=1 to lin[0] do
for j:=1 to f[orig][0] do
begin
w:=i+j-1;
num[w]:=lin[i]*f[orig][j]+num[w];
num[w+1]:=(num[w] div 10)+num[w+1];
num[w]:=num[w] mod 10;
end;
if num[num[0]]=0 then dec(num[0]);
mul:=num;
end;
function max(s1,s2:numtype):boolean;
var
i:sys_int;
begin
if s1[0]<s2[0] then
begin max:=true;exit;end
else
if s1[0]>s2[0] then
begin max:=false;exit;end
else
begin
for i:=s1[0] downto 1 do
if s1[i]<>s2[i] then
if s1[i]<s2[i] then
begin max:=true;exit;end
else
begin max:=false;exit;end;
max:=false;
end;
end;
procedure dp;
var
i,j:sys_int;
maxnum:numtype;
begin
// f[i,j]=max{ f[k,j-1]*g(k+1,i) }
//--> f[i]=max{ f[k]*g(k+1,i) }
for i:=1 to n do
begin
f[0][0]:=1;
f[0][1]:=1;
f[i]:=mul(0,1,i);
end;
for j:=2 to m do
for i:=n downto j do
begin
maxnum[0]:=-maxint;
for k:=j-1 to i-1 do
if max( maxnum,mul(k,k+1,i) ) then
maxnum:=num;
f[i]:=maxnum;
end;
for i:=f[n][0] downto 1 do
write(f[n][i]);
writeln;
end;
begin
init;
dp;
end.