题目链接:

Clone

Time Limit: 2000/1000 MS (Java/Others)   

 Memory Limit: 65536/65536 K (Java/Others)

Problem Description
 
After eating food from Chernobyl, DRD got a super power: he could clone himself right now! He used this power for several times. He found out that this power was not as perfect as he wanted. For example, some of the cloned objects were tall, while some were short; some of them were fat, and some were thin.

More evidence showed that for two clones A and B, if A was no worse than B in all fields, then B could not survive. More specifically, DRD used a vector v to represent each of his clones. The vector v has n dimensions, representing a clone having N abilities. For the i-th dimension, v[i] is an integer between 0 and T[i], where 0 is the worst and T[i] is the best. For two clones A and B, whose corresponding vectors were p and q, if for 1 <= i <= N, p[i] >= q[i], then B could not survive.

Now, as DRD's friend, ATM wants to know how many clones can survive at most.

 
Input
 
The first line contains an integer T, denoting the number of the test cases.

For each test case: The first line contains 1 integer N, 1 <= N <= 2000. The second line contains N integers indicating T[1], T[2], ..., T[N]. It guarantees that the sum of T[i] in each test case is no more than 2000 and 1 <= T[i].

 
Output
 
For each test case, output an integer representing the answer MOD 10^9 + 7.
 
Sample Input
 
2
1
5
2
8 6
 
Sample Output
 
1
7
 
题意:
 
 
 
思路:
 
dp[i][j]表示前j个人和为i的方案数;
dp[i+k][j]=∑dp[i][j-1](0<=k<=a[j]);
结果为dp[sum/2][n],真是谜一样的答案;
sum=∑t[i];
AC代码:
 
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+;
typedef long long ll;
const ll mod=1e9+;
int t,n,a[];
ll dp[][];
int main()
{
scanf("%d",&t);
while(t--)
{
int sum=,ans=;
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
ans+=a[i];
}
memset(dp,,sizeof(dp));
for(int i=;i<=a[];i++)
{
dp[i][]=;
}
for(int i=;i<=n;i++)
{
sum+=a[i];
for(int j=;j<=a[i];j++)
{
for(int k=;k<=sum;k++)
{
dp[k+j][i]+=dp[k][i-]%mod;
dp[k+j][i]%=mod;
}
}
}
printf("%lld\n",dp[ans/][n]);
}
return ;
}
 

hdu-5000 Clone(dp)的更多相关文章

  1. HDU 5000 Clone(离散数学+DP)(2014 ACM/ICPC Asia Regional Anshan Online)

    Problem Description After eating food from Chernobyl, DRD got a super power: he could clone himself ...

  2. hdu 5000 Clone

    dp,用dp[i][j],表示和为i的前j个维度的种类.其中arr[i],表示第i维的最大值. 则\begin{equation} dp[i][j] = \sum_{0 \leq k \leq \mi ...

  3. hdu 4123 树形DP+RMQ

    http://acm.hdu.edu.cn/showproblem.php? pid=4123 Problem Description Bob wants to hold a race to enco ...

  4. hdu 4507 数位dp(求和,求平方和)

    http://acm.hdu.edu.cn/showproblem.php?pid=4507 Problem Description 单身! 依旧单身! 吉哥依旧单身! DS级码农吉哥依旧单身! 所以 ...

  5. hdu 3709 数字dp(小思)

    http://acm.hdu.edu.cn/showproblem.php?pid=3709 Problem Description A balanced number is a non-negati ...

  6. hdu 4352 数位dp + 状态压缩

    XHXJ's LIS Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  7. hdu 4283 区间dp

    You Are the One Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  8. HDU 2829 区间DP & 前缀和优化 & 四边形不等式优化

    HDU 2829 区间DP & 前缀和优化 & 四边形不等式优化 n个节点n-1条线性边,炸掉M条边也就是分为m+1个区间 问你各个区间的总策略值最少的炸法 就题目本身而言,中规中矩的 ...

  9. HDOJ(HDU).2844 Coins (DP 多重背包+二进制优化)

    HDOJ(HDU).2844 Coins (DP 多重背包+二进制优化) 题意分析 先把每种硬币按照二进制拆分好,然后做01背包即可.需要注意的是本题只需要求解可以凑出几种金钱的价格,而不需要输出种数 ...

  10. HDOJ(HDU).1059 Dividing(DP 多重背包+二进制优化)

    HDOJ(HDU).1059 Dividing(DP 多重背包+二进制优化) 题意分析 给出一系列的石头的数量,然后问石头能否被平分成为价值相等的2份.首先可以确定的是如果石头的价值总和为奇数的话,那 ...

随机推荐

  1. 邁向IT專家成功之路的三十則鐵律 鐵律十二:IT人養生之道-德行

    所謂的「養生」在中國古代裡所指的是針對內在精神層面修為的提升,到了近代中醫所謂的養生,則除了包含最根本的內在精神層面之外,還涵蓋了外在身體的養護.在現今各行各業的人士當中,嚴格來說都應該要有一套專屬的 ...

  2. 计算广告、推荐系统论文以及DSP综述

    http://www.huxmarket.com/detail/2966 DSP场景假定前提: 以CTR预估为例,向广告主以CPC(OCPC)方式收费,向ADX以CPM方式付费.投放计划受预算限制,在 ...

  3. javascript 怎么操纵OGNL标签

    吧ONGL标签放到html标签中,来操作html的标签就能够了 样例代码: html <div id="categoryid" style="display:non ...

  4. bootstrap3分页

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"% ...

  5. 完美删除vector的内容与释放内存

    问题:stl中的vector容器常常造成删除假象,这对于c++程序员来说是极其讨厌的,<effective stl>大师已经将之列为第17条,使用交换技巧来修整过剩容量.内存空洞这个名词是 ...

  6. iframe截取站点的部分内容

    <div style="width:630px;height:350px;overflow:hidden;border:0px">                  & ...

  7. redirect_uri 參数错误的解决的方法

    我通过java代码去获得用户的openid,一直报redirect_uri. 我页面代码的链接为: https://open.weixin.qq.com/connect/oauth2/authoriz ...

  8. POJ 3469(Dual Core CPU-最小割)[Template:网络流dinic V2]

    Language: Default Dual Core CPU Time Limit: 15000MS   Memory Limit: 131072K Total Submissions: 19321 ...

  9. 《Android Studio有用指南》7.1 AndroidStudio代码检查工具概述

    本文节选自<Android Studio有用指南> 作者: 毕小朋 博客: http://blog.csdn.net/wirelessqa 眼下本书已上传到百度阅读, 在百度中搜索[Anr ...

  10. shift:解决shell编程中的入渗问题

    我说过了,shell是我的常规武器,目前虽然还不纯熟,但是我爱shell这门语言,在Linux下面混,总要写脚本.程序员是有基因,对编程语言是有偏好的,你让我写C代码,我会觉得很爽,会有困难,会有痛苦 ...