HDOJ 5000 Clone
所有的属性,以满足一定的条件,是,财产和等于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
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.
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].
2
1
5
2
8 6
1
7
#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的更多相关文章
- 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 ...
- hdu 5000 Clone
dp,用dp[i][j],表示和为i的前j个维度的种类.其中arr[i],表示第i维的最大值. 则\begin{equation} dp[i][j] = \sum_{0 \leq k \leq \mi ...
- Java的clone机制(及String的特殊性)
1. Clone&Copy 假设现在有一个Employee对象,Employee tobby =new Employee(“CMTobby”,5000),通常我们会有这样的赋值Employee ...
- java中的clone
.clone 要实现cloneable接口: .深度clone和浅度clone .对象.clone() 1. Clone&Copy 假设现在有一个Employee对象,Employe ...
- 【HDOJ】4775 Infinite Go
其实是一道模拟题,并查集用来优化.还可以的一道题目. /* 4775 */ #include <iostream> #include <sstream> #include &l ...
- java Clone()克隆
转自:http://www.blogjava.net/orangelizq/archive/2007/10/17/153573.html 现在Clone已经不是一个新鲜词语了,伴随着“多莉”的产生这个 ...
- Java clone() 浅克隆与深度克隆(转)
以下文字转自:桔子园 http://www.blogjava.net/orangelizq/archive/2007/10/17/153573.html 现在Clone已经不是一个新鲜词语了,伴随着“ ...
- java clone对象
本文转载至 http://blog.csdn.net/shootyou/article/details/3945221 现在Clone已经不是一个新鲜词语了,伴随着“多莉”的产生这个词语确实很“火”过 ...
- Java clone() 浅克隆与深度克隆
内容转自:http://www.blogjava.net/orangelizq/archive/2007/10/17/153573.html 现在Clone已经不是一个新鲜词语了,伴随着“多莉”的产生 ...
随机推荐
- PPTP和L2TP的区别
PPTP是点到点的隧道协议,服务器端使用TCP 的1723端口,同时使用GRE协议,加密上使用MPPE.位于NAT后的客户端连接会有问题. L2TP是二层隧道VPN,使用IPsec 进行加密,服务器端 ...
- C#的百度地图开发(四)前端显示与定位
原文:C#的百度地图开发(四)前端显示与定位 有了这些定位信息,那要如何在前端的页面上显示出来呢?这需要用到百度地图的JavaScript的API.下面是示例代码. 前端代码 <%@ Page ...
- SQL Server Compact免安装部署
原文:SQL Server Compact免安装部署 情况 应用程序中的EF使用了SQL Server Compact,打包部署到客户机器上后提示数据库连接异常,信息类似”配置节“.”Provider ...
- httpcomponents-client-4.4.x
Chapter 1. Fundamentals Prev Next Chapter 1. Fundamentals 1.1. Request execution The most essent ...
- android--自己定义ProgressDialog显示位置(其他Dialog子类都能够设置)
1.普通情况下,系统默认的Dialog显示位置为屏幕居中: pbDialog = new ProgressDialog(MainActivity.this); pbDialog.setMessage( ...
- MFC控件(15):Tooltip
在各种软件产品中我们经常碰到把鼠标放到一个控件上时会弹出关于该控件的一些提示信息.这就是tooltip. 在MFC中使用该功能可以使用类CToolTipCtrl.假如要让鼠标放到按钮IDC_BTN上时 ...
- Hadoop-2.2.0中国文档—— MapReduce 下一代 -- 公平调度
目的 此文档描写叙述了 FairScheduler, Hadoop 的一个可插入式的调度器,同意 YARN 应用在一个大集群中公平地共享资源. 简单介绍 公平调度是一种分配资源给应用的方法.以致到最后 ...
- Linux 软连接与硬连接
Linux 软连接与硬连接 对于一个文件来说,有唯一的索引接点与之相应,而对于一个索引接点号,却能够有多个文件名称与之相应.因此,在磁盘上的同一个文件能够通过不同的路径去訪问该文件.注意在Linux下 ...
- SQL在declare声明变量
在sql添加的声明变量. declare @local_variable data_type 你需要指定一个变量声明的类型, 能够使用set和select对变量进行赋值, 在sql语句中就能够使用@l ...
- 802.11(wi-fi)的PHY层(编码与调制方法)
版本概要: 802.11-2007是目前的基础版本,之前的过时版本不考虑. 2009是较新的版本,就是目前最普及的802.11n.(100Mb/s) 2012就是传说中的802.11ac,工作在5G, ...