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


相关推荐

  • windows程序设计第五版_windows程序设计入门

    windows程序设计第五版_windows程序设计入门Ellipse函数的用法函数功能:该函数用于画一个椭圆,椭圆的中心是限定矩形的中心,使用当前画笔画椭圆,用当前的画刷填充椭圆。函数原型:BOOL Ellipse(HDC hdc, int nLeftRect, int nTopRect, nRightRect, int nBottomRect);参数:hdc:设备环境句柄。nLeftRect:指定限定矩形左上角的X坐标。nTopRect…

    2022年8月18日
    6
  • centos 7如何将 网卡ens33 修改成 eth0「建议收藏」

    centos 7如何将 网卡ens33 修改成 eth0「建议收藏」文章目录linux网卡名称命名命名规则修改eth0方法linux网卡名称命名命名规则CENTOS6的网卡命名方式它会根据情况有所改变而非唯一且固定,在CENTOS6之前,网络接口使用连续号码命名:eth0、eth1等,当增加或删除网卡时,名称可能会发生变化CENTOS7命名方式采用dmidecode采集命名方案,以此来得到主板信息;它可以实现网卡名字永久唯一化(dmidecode这个命令可以采集有关硬件方面的信息)对网络设备的命名方式:1)如果Firmware(固件)或B

    2025年5月22日
    5
  • Apache2.4使用require指令进行访问控制–允许或限制IP访问/通过User-Agent禁止不友好网络爬虫…

    Apache2.4使用require指令进行访问控制–允许或限制IP访问/通过User-Agent禁止不友好网络爬虫…

    2021年9月23日
    49
  • 滴滴开源敏捷测试用例管理平台!

    点击上方“全栈程序员社区”,星标公众号 重磅干货,第一时间送达 简介 AgileTC是一套敏捷的测试用例管理平台,具备与xmind等脑图工具一致的操作体验。支持测试用例管理、执行计…

    2021年6月25日
    83
  • cj广告联盟「建议收藏」

    cj广告联盟「建议收藏」CommissionJunction(简称CJ)是目前国外最大的综合网络广告商,拥有超过1000家赞助商,且每天都有新的公司加入,支持中文网站,是站长赚钱的第一选择。公司业务广泛,技术完善,相对于其它综合网络广告商的优点是由其每月统一付款,但正应为如此,所以要求严格。公司支持中文网站,每推荐一人获得$1.5美金。最小起付额为25美元,每月统计付款。CJ,全称Com…

    2022年9月19日
    2
  • python分析人口出生率代码_国家统计局居然也能用的上Python?人口数据Python脚本了解一下?…[通俗易懂]

    python分析人口出生率代码_国家统计局居然也能用的上Python?人口数据Python脚本了解一下?…[通俗易懂]原标题:国家统计局居然也能用的上Python?人口数据Python脚本了解一下?通过采集国家统计局“国家数据”网站中提供的中国历年人口数据,并对数据进行可视化的探索,发现了一些有意思和令人深思的现象和趋势。有一些小伙伴后台留言希望公布一下采集“国家数据”网站人口数据的代码,在这里,就将总人口、人口出生率、人口年龄结构和人口平均寿命4项数据的代码公布出来,方便大家学习和使用。文章目录涉及到的模块在这…

    2025年8月30日
    7

发表回复

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

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