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)
全栈程序员-站长的头像全栈程序员-站长

相关推荐

  • 5种很牛的两位数乘法速算方法「建议收藏」

    5种很牛的两位数乘法速算方法「建议收藏」5种很牛的两位数乘法速算方法第一种:十几乘以任意两位数公式推导(10+b)(10c+d)=100c+10(bc+d)+bd=10(10c+bc+d)+bd=10((10c+d)+bc)+bd 方法:如果c=1,那么就是一个因数,加上另一个因数的尾数,做前积;两个因数的乘积,做尾积应用举例:11×11=|11+1||1×1|=12112×14=|12+4||2×4|=1681

    2022年6月8日
  • 新安装idea,需要设置好的几个地方。

    设置编码格式。 设置maven。 如果不设置,那之前下载的jar包还得重新下载。 设置快捷键。 我使用eclipse的快捷键。 设置主题。 设置字体。 设置JDK. 未完待续。。。。。。

    2022年3月13日
  • Semantic Drone Dataset(语义无人机数据集)使用方法「建议收藏」

    Semantic Drone Dataset(语义无人机数据集)使用方法「建议收藏」数据集介绍SemanticDroneDataset数据集下载地址该语义无人机数据集专注于城市场景的语义理解,以提高无人机自主飞行和着陆程序的安全性。该图像描绘了在距地面5至30米的高度从最低点(鸟瞰)视角拍摄的20多座房屋。高分辨率相机用于获取尺寸为6000x4000px(24Mpx)的图像。训练集包含400张公开可用的图像,测试集包含200张私有图像。该语义分割数据集包括20个种类:树、草、其他植被、污垢、碎石岩石、水、铺砌面积、水池、人狗、车、自行车、屋顶、墙

    2022年8月15日
  • Oracle技术之如何分析执行计划(一)

    Oracle技术之如何分析执行计划(一)

    2021年8月26日
  • Shiro框架基本知识及应用「建议收藏」

    Shiro框架基本知识及应用「建议收藏」1.Shiro基本知识1.目前市面主流的安全框架:shiro:轻量级的,使用很方便,灵活,是apache提供的,在任何框架的SpringSecurity:是Spring家族的一部分,很多项目中会使用spring全家桶,相对与shiro来说,springSecurity更重量级,必须要求spring环境;相对shiro而言,功能更强大2.什么是Shiro?Shiro是apache旗下一个开源安全框架,它将软件系统的安全认证相关的功能抽取出来,实现用户身份认证、权限授权、加密、会话管理等功

    2022年9月8日
  • VCL 控件分类_验证控件的分类

    VCL 控件分类_验证控件的分类TForm右下角小窗体中调整form显示位置。动态窗体:主窗体和动态生成的窗体(Project|Options|Forms)在一个头文件中添加另一个头文件(File|UseUnit)newTForm2(this);(this:指以此为容器)ShowModal(),Show();(是否当前窗体关闭后才能操作父窗体:模态方式,非模态方式)Close();(关闭窗体)(在Eve

    2022年9月25日

发表回复

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

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