hdu 5000 Clone 2014 ACM/ICPC Asia Regional Anshan Online
来源:互联网 发布:office mac破解版迅雷 编辑:程序博客网 时间:2024/04/29 03:44
Clone
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 447 Accepted Submission(s): 215
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.
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].
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
21528 6
Sample Output
17
Source
2014 ACM/ICPC Asia Regional Anshan Online
Recommend
hujie | We have carefully selected several similar problems for you: 5017 5016 5015 5013 5012
题意:一个克隆人有n个属性,如果一个克隆人的任何一个属性都不大于另一个,他就不应该存在,给你n和每个属性的最大值,问最多能有多少克隆人存在。
思路:如果说能保证最多的克隆人存在,那么他们的属性和一定相等,且为所有最大属性和的一半。(好像很有道理,却说不出来哪有道理的结论)。比赛的时候神犇推得出来背包一下就过掉了,我这样的小菜做这种题只能靠yy了。知道结论直接01背包求能到达sum/2的所有情况就好了。
#include <iostream>#include <stdio.h>#include <cmath>#include <cstring>#include <algorithm>using namespace std;const int mod=1e9+7;const int N=2005;int dp[N*N/2],a[N];int main(){ int n,t,sum; scanf("%d",&t); while(t--){ scanf("%d",&n); sum=0; for(int i=0;i<n;i++){ scanf("%d",&a[i]); sum+=a[i]; } sum/=2; memset(dp,0,sizeof(dp)); dp[0]=1; for(int i=0;i<n;i++){ for(int j=sum;j>=0;j--){ for(int k=1;k<=a[i]&&k<=j;k++) dp[j]=(1ll*dp[j]+dp[j-k])%mod; } } printf("%d\n",dp[sum]); } return 0;}
0 0
- HDU 5000 Clone / 2014 ACM/ICPC Asia Regional Anshan Online
- hdu 5000 Clone 2014 ACM/ICPC Asia Regional Anshan Online
- hdu 5000 Clone 2014 ACM/ICPC Asia Regional Anshan Online
- HDU 5000 Clone 规律+dp 2014 ACM/ICPC Asia Regional Anshan Online
- 2014 ACM/ICPC Asia Regional Anshan Online D Clone
- HDU 4998 Rotate / 2014 ACM/ICPC Asia Regional Anshan Online
- HDU 5001 Walk / 2014 ACM/ICPC Asia Regional Anshan Online
- hdu 4998 Rotate 2014 ACM/ICPC Asia Regional Anshan Online
- 2014 ACM/ICPC Asia Regional Anshan Online
- 2014 ACM/ICPC Asia Regional Anshan Online HDU 4998 HDU 5000 HDU 5001 HDU 5003
- HDU4998 Rotate (2014 ACM/ICPC Asia Regional Anshan Online)
- HDU 5003 Osu! 水题 2014 ACM/ICPC Asia Regional Anshan Online
- HDU 4998 Rotate 计算几何 2014 ACM/ICPC Asia Regional Anshan Online
- hdu 5003 Osu! 水题 2014 ACM/ICPC Asia Regional Anshan Online
- hdu 5001 Walk 概率dp 2014 ACM/ICPC Asia Regional Anshan Online
- poj 5001 Walk &&2014 ACM/ICPC Asia Regional Anshan Online 1005(dp)
- hdu 5036 Explosion 2014 ACM/ICPC Asia Regional Beijing Online
- hdu 5033 Building 2014 ACM/ICPC Asia Regional Beijing Online
- [English]师兄师姐用英语怎么说
- 深入理解操作系统的管程,进程,线程(二)
- VI命令用法
- 我一方面在最低年级停滞不前
- 被虐开始
- hdu 5000 Clone 2014 ACM/ICPC Asia Regional Anshan Online
- h264基础知识 宏块,片
- if分支语句
- API函数
- HDU 1195 Open the Lock
- 黑马程序员——网络编程学习笔记
- sql语句优化
- ZJU 3787
- LeetCode - 3Sum