HDU-5000 clone Anshan Network Competition D Question DP + Conjecture

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.