所有的属性,以满足一定的条件,是,财产和等于sum/2结果最大.

Clone

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 574    Accepted Submission(s): 277

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
 
Source
 

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; typedef long long int LL; const LL mod=(1e9+7); int v[2020],n;
LL sum,dp[2][2000400]; int main()
{
int T_T;
scanf("%d",&T_T);
while(T_T--)
{
scanf("%d",&n);
sum=0;
for(int i=0;i<n;i++)
{
scanf("%d",v+i);
sum+=v[i];
}
memset(dp,0,sizeof(dp));
for(int i=0;i<n;i++)
{
if(i==0)
{
for(int j=0;j<=v[i];j++) dp[0][j]=1;
continue;
}
for(int j=0;j<=sum/2;j++)
{
int temp=0;
for(int k=0;k<=v[i]&&k<=j;k++)
{
temp=(temp+dp[(i%2)^1][j-k])%mod;
}
dp[i%2][j]=temp;
}
}
printf("%d\n",dp[(n-1)%2][sum/2]);
}
return 0;
}

版权声明:本文博客原创文章,博客,未经同意,不得转载。

HDOJ 5000 Clone的更多相关文章

  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. Java的clone机制(及String的特殊性)

    1. Clone&Copy 假设现在有一个Employee对象,Employee tobby =new Employee(“CMTobby”,5000),通常我们会有这样的赋值Employee ...

  4. java中的clone

    .clone 要实现cloneable接口: .深度clone和浅度clone .对象.clone() 1. Clone&Copy      假设现在有一个Employee对象,Employe ...

  5. 【HDOJ】4775 Infinite Go

    其实是一道模拟题,并查集用来优化.还可以的一道题目. /* 4775 */ #include <iostream> #include <sstream> #include &l ...

  6. java Clone()克隆

    转自:http://www.blogjava.net/orangelizq/archive/2007/10/17/153573.html 现在Clone已经不是一个新鲜词语了,伴随着“多莉”的产生这个 ...

  7. Java clone() 浅克隆与深度克隆(转)

    以下文字转自:桔子园 http://www.blogjava.net/orangelizq/archive/2007/10/17/153573.html 现在Clone已经不是一个新鲜词语了,伴随着“ ...

  8. java clone对象

    本文转载至 http://blog.csdn.net/shootyou/article/details/3945221 现在Clone已经不是一个新鲜词语了,伴随着“多莉”的产生这个词语确实很“火”过 ...

  9. Java clone() 浅克隆与深度克隆

    内容转自:http://www.blogjava.net/orangelizq/archive/2007/10/17/153573.html 现在Clone已经不是一个新鲜词语了,伴随着“多莉”的产生 ...

随机推荐

  1. SE 2014年3月31日

    一. 描述OSPF划分区域的优势. OSPF划分区域的优势主要表现在以下几个方面: 1. 当网络中路由器的数量增大时,划分区域有利于减轻一部分性能较低的设备的处理和维护LSA数据库. 2. 区域的划分 ...

  2. java參数传递方式问题

    java的參数传递方式到底是值传递还是引用传递,这一直是一个争论不休的问题,一直以来没有形成统一意见. 在这里,我也仅仅是说一说个人见解,不保证是对的,全当是抛砖引玉. 首先我的观点是java採用的是 ...

  3. veridata实验举例(6)验证agent启动先后顺序是否对捕获update操作有影响

    veridata实验举例(6)验证agent启动先后顺序是否对捕获update操作有影响 续接veridata实验系列  上篇:"veridata实验举例(5)改动主键上的列值.update ...

  4. ThreadSafeClientConnManager的20个例子

    Java Code Examples for org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager The following are ...

  5. 分布式Unique ID的生成方法

    分布式Unique ID的生成方法 分布式的Unique ID的用途如此广泛,从业务对象Id到日志的TraceId,本文总结了林林总总的各种生成算法. 1. 发号器 我接触的最早的Unique ID, ...

  6. HGE引擎 - 绘制,声音,碰撞处理

    原帖地址:http://blog.csdn.net/i_dovelemon/article/details/8818037 另外,年代久远,该引擎官网早已上不去了!!! 1.库的安装和下载 从官网上h ...

  7. Allegro绘制PCB流程

    单位换算 1mil = 0.0254 mm 1mm = 39.3701 mil 默认情况下我们更倾向于使用mil单位绘制PCB板. 1 新建工程,File --> New... --> [ ...

  8. windows phone 加速计(5)

    原文:windows phone 加速计(5) 在windows phone 中存在着加速计,我们可以利用加速计获得用户手机的状态,根据手机状态调整我们的程序,这样会更人性化:windows phon ...

  9. &#39;Basic&#39; attribute type should not be a persistence entity/a container

    正在使用IDEA进行HIbernate开发时间,从datasource由此产生的实体映射不理想.需要手动更改. 投身于实体类的属性Setter时间.临时有红tip:'Basic' attribute ...

  10. Red Gate系列之二 SQL Source Control 3.0.13.4214 Edition 数据库版本控制器 完全破解+使用教程

    原文:Red Gate系列之二 SQL Source Control 3.0.13.4214 Edition 数据库版本控制器 完全破解+使用教程 Red Gate系列之二 SQL Source Co ...