太水了,背包DP. (转载请注明出处:http://www.cnblogs.com/Kalenda/) ; var n,f,i,j,ans,t,tt:longint; q:array[..] of longint; a:array[..,..] of longint; begin readln(n,f); to n do begin readln(q[i]); q[i]:=q[i] mod f; end; a[,]:=; to n do to f do a[i,j]:=(a[i-,(j-q[i]…