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


相关推荐

  • pycharm提示no python interpreter_pycharm failed to create virtual

    pycharm提示no python interpreter_pycharm failed to create virtual学习笔记遇到问题在学习时,用pycharm打开浏览器的时候(我用的是谷歌浏览器,别的浏览器也用这个思路解决)发现提示说找不到这个文件解决方法:打开设置(File→Settings)点击工具,浏览器(Tools→WebBrowsers)在工具那一项中,点击浏览器,再在右边的浏览器中,找到自己要用的浏览器在浏览器对应的路径中修改路径(找到该浏览器下载在本机的位置)这一步老师…

    2022年8月27日
  • linux(1)Mac上传文件到Linux服务器

    linux(1)Mac上传文件到Linux服务器前言我们使用mac时,想让本地文件上传至服务器,该怎么办呢windows系统,我们可以使用xftp或者rz命令,那么mac呢?mac系统,我们可以使用sftp、scp或者rz命令,本文介绍sft

    2022年7月31日
  • centos系统大量time wait占用的解决

    centos系统大量time wait占用的解决统计在一台前端机上高峰时间TCP连接的情况,统计命令:netstat-n|awk’/^tcp/{++S[$NF]}END{for(ainS)printa,S[a]}’除了ESTABLISHED,可以看到连接数比较多的几个状态是:FIN_WAIT1,TIME_WAIT,CLOSE_WAIT,SYN_RECV和…

    2022年5月9日
  • 云 云计算_openapi开发接口

    云 云计算_openapi开发接口http://www.cnblogs.com/skyme/p/3435565.html介绍OpenAPI即开放API,也称开放平台。所谓的开放API(OpenAPI)是服务型网站常见的一种应用,网站的服务商将自己的网站服务封装成一系列API(ApplicationProgrammingInterface,应用编程接口)开放出去,供第三方开发者使用,这种行为就叫做开放网站的API,所

    2022年9月27日
  • msm8953之spi配置

    msm8953之spi配置//===========================================spi5msm8953.dtsialiases{spi5=&spi_5;};spi_5:spi@7af5000{/*BLSP1QUP5*/compatible=”qcom,spi-qup-v2″;…

    2022年10月18日
  • Java 编码问题

    Java 编码问题

    2021年10月7日

发表回复

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

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