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


相关推荐

  • ant下载地址

    ant下载地址http://ant.apache.org/bindownload.cgi

    2022年7月15日
    24
  • 博客大巴,自动登录,并发布信息开发小计。

    博客大巴,自动登录,并发布信息开发小计。工具准备:Fiddler相关网页:登录页面:http://passport.blogbus.com/login信息发布信息:http://www.blogbus.com/user/?blogid=49

    2022年6月30日
    26
  • 那四年,我们一起逝去的青春

    今天是2011年10月1日,是我出生后的第21个国庆节,也是大学生涯里最后一个国庆节,这篇日志可能有点长,闲着蛋疼的童鞋可以泡杯咖啡,一边喝一边看,就当看笑话好了。日志发出来估计已经是几个月后的事了,这也是记录了大学里的点点滴滴。前几天大一新生的军训闭幕式也落下了帷幕,上周五毕业设计的初稿已经发下来了,室友在实习的公司上班马上就要发工资了,考研的童鞋已经进入了积极备战的状态,据说毕

    2022年4月8日
    39
  • vuerouter配置_route删除路由

    vuerouter配置_route删除路由介绍VueRouter是Vue.js官方的路由管理器。它和Vue.js的核心深度集成,让构建单页面应用变得易如反掌。包含的功能有:嵌套的路由/视图表模块化的、基于组件的路由配置路由参

    2022年7月29日
    8
  • django mysqlclient_mac好用的ssh

    django mysqlclient_mac好用的sshmac系统安装mysqlclient时,会报错OSError:mysql_confignotfound解决办法在项目路径下输入以下内容PATH="$PATH":/usr

    2022年7月29日
    9
  • 超级用户权限root_小米开发版root权限获取

    超级用户权限root_小米开发版root权限获取小米手机6X有没有办法开启ROOT超级权限?我们知道,安卓手机有ROOT超级权限,如果手机开启root相关权限,能够实现更好的功能,举例子,我们部门的营销部门,使用一些营销软件都需要在ROOT超级权限下执行,如果手机没办法获的root的权限,即没办法正常使用具体的功能。小米手机6X开发版系统自身拥有root权限管理工具,如果你使用的是小米手机6X稳定版,建议可以先将小米手机6X刷入开发版,再进…

    2025年6月18日
    5

发表回复

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

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