hdu5000 Clone dp
来源:互联网 发布:中国股市现状 知乎 编辑:程序博客网 时间:2024/06/11 19:35
Clone
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1596 Accepted Submission(s): 737
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
图解:http://www.cnblogs.com/oyking/p/3970845.html
思路:http://www.cnblogs.com/xiaohongmao/p/3988142.html
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int mod = 1e9 + 7;int T, n, sum;int t[2005], dp[2005][2005];int main(){cin >> T;while (T--) {scanf("%d", &n);sum = 0;for (int i = 0; i < n; i++) {scanf("%d", &t[i]);sum += t[i];}memset(dp, 0, sizeof(dp));sum /= 2;for (int i = 0; i <= t[0]; i++) {dp[0][i] = 1;}for (int i = 1; i < n; i++) {for (int j = 0; j <= sum; j++) {for (int k = 0; k <= j && k <= t[i]; k++) {dp[i][j] = (dp[i][j] + dp[i - 1][j - k]) % mod;}}}printf("%d\n", dp[n - 1][sum]);}return 0;}
0 0
- DP - hdu5000 Clone
- hdu5000 Clone(dp+规律)
- hdu5000 Clone dp
- HDU5000 Clone(计数dp)
- hdu5000 Clone
- HDU5000 dp
- hdu5000(dp)
- HDU5000 区间dp
- hdu5000 Clone 鞍山网络赛D题
- hdu5000一道很有意思的DP
- 【DP】 HDOJ 5000 Clone
- HDU - 5000 Clone DP
- hdu 5000 Clone(dp)
- HDU 5000 Clone(背包dp)
- hdu oj 5000 Clone DP
- HDU 5000 Clone 规律+dp
- HDU 5000 Clone 猜想性质 DP
- hdu 5000 Clone (dp + 找规律)
- python 核心编程&对象
- ProgressDialog使用总结
- lxml: Cannot import lxml.html.soupparser.fromstring, depends on outdated BeautifulSoup
- 【数据结构】算法10.4-10.5 插入排序-希尔
- git使用方法
- hdu5000 Clone dp
- Java线程之线程的五种状态
- lightoj 1021 从当前转移到其他状态的状压dp
- Java基础——实现UDP发送数据和接收数据
- 数据库实战(四)数据库主从复制
- R语言内存管理
- 常用less
- 极光推送注册、接收、点击打开推送通知
- Python学习笔记