A person can clone his/her own clone body. One clone body has n aspects. If one clone body is inferior to another in all aspects, it cannot survive, ask how many clones can survive at the same time. Idea: when the maximum value is obtained, the sum of attributes of each clone body must be the same, and this is the highest attribute and 1/2 of all aspects. The problem is that N numbers constitute the number of sum/2 solutions.
# Include <iostream> # include <cstdio> # include <cmath> # include <queue> # include <algorithm> # include <cstring> # include <queue> # include <iomanip> using namespace STD; const int mod = 1e9 + 7; const int maxn = 2222; int N; int A [maxn]; int DP [maxn]; int main () {<span style = "white-space: pre"> </span> int t; <span style = "white-space: pre "> </span> int sum = 0; <span style =" white-space: pre "> </span> scanf (" % d ", & T ); <span style = "white-space: pre"> </span> while (t --) <span style = "white-space: pre "> </span> {<span style =" white-space: pre "> </span> sum = 0; <span style =" white-space: pre "> </span> scanf (" % d ", & N); <span style =" white-space: pre "> </span> for (INT I = 1; I <= N; I ++) <span style =" white-space: pre "> </span> {<span style =" white-space: pre "> </span> scanf (" % d ", & A [I]); <span style = "white-space: pre"> </span> sum + = A [I]; <span style = "white-space: pre "> </SPAN >}< span style =" white-space: pre "> </span> sum/= 2; <span style =" white-space: pre "> </span> memset (DP, 0, sizeof (DP); <span style =" white-space: pre "> </span> DP [0] = 1; <span style =" white-space: pre "> </span> for (INT I = 1; I <= N; I ++) // calculate the number of sum solutions composed of N digits in the backpack <span style = "white-space: pre "> </span> {<span style =" white-space: pre "> </span> for (int K = sum; k> = 0; k --) <span style = "white-space: pre"> </span> {<span style = "white-space: pre"> </span> for (Int J = 1; j <= A [I]; j ++) <span style = "white-space: pre"> </span> {<span style = "white-space: pre "> </span> If (k-j <0) <span style =" white-space: pre "> </SPAN >{< span style =" white-space: pre "> </span> break; <span style =" white-space: pre "> </SPAN >}< span style =" white-space: pre "> </span> DP [k] = (DP [k-J] + dp [k]) % MOD; <span style =" white-space: pre "> </SPAN >}< span style =" white-space: pre "> </SPAN >}< span style =" white-space: pre "> </SPAN >}< span style =" white-space: pre "> </span> printf (" % d \ n ", DP [Sum]); <span style = "white-space: pre"> </SPAN >}< span style = "white-space: pre"> </span> return 0 ;}
HDU-5000 clone Anshan Network Competition D Question DP + Conjecture