HDU 5000 clone
There are three questions in this case .. I am stuck on this question. Fortunately, I have saved my quota.
Idea: when the maximum value is introduced, each person's attributes must be the same, and this and must be all and/2. In this case, the problem is converted to N numbers, to combine the sum/2 methods, you can use the DP backpack to push it again.
Sum/2 was not introduced at the scene.
Code:
#include <cstdio>#include <cstring>const int MOD = 1000000007;const int N = 2005;int t, n, dp[N], T[N];int main() {scanf("%d", &t);while (t--) {scanf("%d", &n);int sum = 0;for (int i = 1; i <= n; i++) {scanf("%d", &T[i]);sum += T[i];}sum /= 2;memset(dp, 0, sizeof(dp));dp[0] = 1;for (int i = 1; i <= n; i++) {for (int k = sum; k >= 0; k--) {for (int j = 1; j <= T[i]; j++) {if (k - j < 0) break;dp[k] = (dp[k] + dp[k - j]) % MOD;}}}printf("%d\n", dp[sum]);}return 0;}
HDU 5000 clone (Anshan Network Competition D)