In fact, it is a strange DP question, and zookeeper won't do it again...
After reading the questions of vfk, you can figure out what the problem is:
If f [I, j] indicates that the maximum part is cut when J balls exist in the I dimension
F [I, j] = f [I, j-1] + F [I-1, J-1]
The first part is the largest number of balls in the first J-1, and the second part is the understanding:
The J-1 ball is followed by another ball, so the optimal condition is that the last ball and the first J-1 ball are intersection.
For the I-1 dimension interview, the intersection is the optimal number of I-2 Dimension Spaces <=> I-1 dimension spaces divided by J-1 I-2 balls.
Certificate completed...
1 /************************************************************** 2 Problem: 1197 3 User: rausen 4 Language: Pascal 5 Result: Accepted 6 Time:0 ms 7 Memory:264 kb 8 ****************************************************************/ 9 10 var11 n, m : longint;12 f : array[0..20, 0..200] of int64;13 cal : array[0..20, 0..200] of boolean;14 15 procedure pre_work;16 var17 i, j : longint;18 19 begin20 for i := 1 to n do begin21 f[i, 1] := 2;22 cal[i, 1] := true;23 end;24 for j := 1 to m do begin25 f[1, j] := 2 * j;26 cal[1, j] := true;27 end;28 end;29 30 function calc(x, y : longint) : int64;31 begin32 if cal[x, y] then exit(f[x, y]);33 cal[x, y] := true;34 f[x, y] := calc(x - 1, y - 1) + calc(x, y - 1);35 exit(f[x, y]);36 end;37 38 begin39 readln(m, n);40 fillchar(cal, sizeof(cal), false);41 pre_work;42 writeln(calc(n, m));43 end.
View code
(P.s. The program is P. Do not blame me>. <... It was previously written ...!)
Bzoj1197 [hnoi2006] MAGIC OF THE FLOWER FAIRY