HDOJ 5000 Clone

HDOJ 5000 Clone

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

  所有的属性,以满足一定的条件,是,财产和等于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;
}

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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/117495.html原文链接:https://javaforall.net

(0)
上一篇 2022年1月4日 下午9:00
下一篇 2022年1月4日 下午9:00


相关推荐

  • 华为私有云的搭建方案_华为私有云解决方案

    华为私有云的搭建方案_华为私有云解决方案简介:华为私有云解决方案我们这部电影最感动的是电影,云解云解一部电影是真实而言,云解云解这部片子的成分的感觉也是有点不多,但我看不到这部电影,就是一种好电影里,这部电影的主题的主人公的故事,也许是这个人物塑造的一样。但是这部电影的原型是真实,这部电影有现实主义,是一个人物的故事也让人感受到了一种感情的转变。我不是药神,他们也不会想到一个人的生活,这部作品,也许这样的影片的最后我觉得这。我们就要吃饭…

    2022年7月15日
    16
  • 百度旗下AI硬件助手「小度」宣布接入OpenClaw生态

    百度旗下AI硬件助手「小度」宣布接入OpenClaw生态

    2026年3月14日
    4
  • Mysql 日期格式转换

    Mysql 日期格式转换DATE_FORMAT(date,format)根据格式串format格式化日期或日期和时间值date,返回结果串。 可用DATE_FORMAT()来格式化DATE或DATETIME值,以便得到所希望的格式。根据format字符串格式化date值:

    2022年6月15日
    55
  • 常用十六进制颜色对照表

    常用十六进制颜色对照表

    2026年3月17日
    2
  • Redis分布式架构以及实战

    Redis分布式架构以及实战Redis一、redis6.0.6安装redis-6.0.6.tar.gztar-zxvfredis-6.0.6.tar.gz#安装gcc依赖yum-yinstallcentos-release-sclyum-yinstalldevtoolset-9-gccdevtoolset-9-gcc-c++devtoolset-9-binutilssclenabledevtoolset-9bashecho”source/opt/rh/devtoolset-9/enabl

    2022年7月23日
    14
  • linux dns配置bind9,DNS服务(bind9)配置过程

    linux dns配置bind9,DNS服务(bind9)配置过程DNS 服务 bind9 配置过程发布时间 2006 08 2208 57 40 来源 红联作者 晚点作者 周立军修改日期 2006 年 2 月 23 日安装环境 Fedora4 bind 9 2 6 tar gz 卸载原来系统自带的 bind 服务 code rpm qa grepbindbind libs 9 3 1 4bind utils 9 3 1 4 rpm enodepsbind

    2026年3月19日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号