测试结果2: 通过本测试点|有效耗时47ms
测试结果3: 测试结果错误.错误结果为:11399
正确结果应为:11400
测试结果4: 通过本测试点|有效耗时47ms
测试结果5: 通过本测试点|有效耗时47ms
测试结果6: 测试结果错误.错误结果为:18446744073709446846
正确结果应为:17366844090418687
测试结果7: 测试结果错误.错误结果为:18446744073709497312
正确结果应为:14023194135285646
测试结果8: 测试结果错误.错误结果为:18446744073709519783
正确结果应为:353223438713994580
测试结果9: 测试结果错误.错误结果为:18446744073709536180
正确结果应为:341857152967402144
测试结果10: 测试结果错误.错误结果为:18446744073709355008
正确结果应为:383746102307848192
提交代码: var sh:array[0..1024,0..1024]of qword;
max:qword;
n,r,g,b,t:longint;
i,j,k:longint;
function pd:qword;
begin
if(sh[i-1,j]+(t+b*(i-1))*j*g)>(sh[i,j-1]+(t+b*i)*(j-1)*g)
then exit(sh[i-1,j]+(t+b*(i-1))*j*g) else exit(sh[i,j-1]+(t+b*i)*(j-1)*g);
end;
begin
readln(n,r,g,b,t);
for i:=1 to n do sh[0,i]:=(g*i*(i-1))div 2;
for i:=1 to n do begin
for j:=1 to (n-i)do begin
sh[i,j]:=pd;
end;
end;
for i:=0 to n do begin
for j:=0 to (n-i) do begin
k:=n-i-j;
if sh[i,j]+k*r*(t+i*b)+k*(j*g)*(t+i*b)>max then max:=sh[i,j]+k*r*(t+i*b)+k*(j*g)*(t+i*b);
end;
end;
writeln(max);
end.
其中的sh[i,j]表示有i个蓝法师,j个绿法师造成的最大伤害,最后的k表示红法师的数量。
如果没有看出来错在哪给我第1(作参考)、3点的测试数据也行。
我老师说QWORD和INT64这两个类型都不太稳定。
用INT64发了一遍,成了这个样子。
测试结果1: 通过本测试点|有效耗时203ms
测试结果2: 通过本测试点|有效耗时47ms
测试结果3: 测试结果错误.错误结果为:11399
正确结果应为:11400
测试结果4: 通过本测试点|有效耗时63ms
测试结果5: 通过本测试点|有效耗时62ms
测试结果6: 测试结果错误.错误结果为:695684284940
正确结果应为:17366844090418687
测试结果7: 测试结果错误.错误结果为:1144048164696
正确结果应为:14023194135285646
测试结果8: 测试结果错误.错误结果为:1404054031182
正确结果应为:353223438713994580
测试结果9: 测试结果错误.错误结果为:1384007756516
正确结果应为:341857152967402144
测试结果10: 测试结果错误.错误结果为:102801997824
正确结果应为:383746102307848192
var i,j:longint;
f:array[0..1024,0..1024]of qword;
max,o,n,r,g,b,t:qword;
begin
readln(n,r,g,b,t);
f[0,0]:=n*r*t;
max:=f[0,0];
for i:=1 to n do
begin
f[i,0]:=(n-i)*r*(t+b*i);
f[0,i]:=f[0,i-1]-r*t+g*(n-i)*t;
if max<f[i,0]then max:=f[i,0];
if max<f[0,i]then max:=f[0,i];
end;
for i:=1 to n do
for j:=1 to n-i do
begin
f[i,j]:=f[i-1,j]+(n-i-j)*r*b+(n-i-j)*(g*j)*b-r*(t+(i-1)*b);
o:=f[i,j-1]+(n-i-j)*g*(t+i*b)-r*(t+i*b);
if o>f[i,j]then f[i,j]:=o;
if f[i,j]>max then max:=f[i,j];
end;
writeln(max);
end.
这样写试试看
反正AC率不重要