Pimp My Ride(poj 2490)

本文介绍了一个基于动态规划的问题——PimpMyRideTime,旨在寻找完成一系列汽车改造任务的最经济顺序。任务包括涂装、内饰装饰等,费用受已完成任务的影响。文章提供了详细的输入输出样例及解析,适用于算法竞赛或动态规划的学习。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Pimp My Ride
Time Limit: 3000MS Memory Limit: 65536K
Total Submissions: 1633 Accepted: 494

Description

Background 
Today, there are quite a few cars, motorcycles, trucks and other vehicles out there on the streets that would seriously need some refurbishment. You have taken on this job, ripping off a few dollars from a major TV station along the way. 
Of course, there's a lot of work to do, and you have decided that it's getting too much. Therefore you want to have the various jobs like painting, interior decoration and so on done by garages. Unfortunately, those garages are very specialized, so you need different garages for different jobs. More so, they tend to charge you the more the better the overall appearance of the car is. That is, a painter might charge more for a car whose interior is all leather. As those "surcharges" depend on what job is done and which jobs have been done before, you are currently trying to save money by finding an optimal order for those jobs. 
Problem 
Individual jobs are numbered 1 through n. Given the base price p for each job and a surcharge s (in US$) for every pair of jobs (i, j) with i != j, meaning that you have to pay additional $s for job i, if and only if job j was completed before, you are to compute the minimum total costs needed to finish all jobs.

Input

The first line contains the number of scenarios. For each scenario, an integer number of jobs n, 1 <= n <= 14, is given. Then follow n lines, each containing exactly n integers. The i-th line contains the surcharges that have to be paid in garage number i for the i-th job and the base price for job i. More precisely, on the i-th line, the i-th integer is the base price for job i and the j-th integer (j != i) is the surcharge for job i that applies if job j has been done before. The prices will be non-negative integers smaller than or equal to 100000.

Output

The output for every scenario begins with a line containing "Scenario #i:", where i is the number of the scenario starting at 1. Then print a single line: 
"You have officially been pimped for only $p" 
with p being the minimum total price. Terminate the output for the scenario with a blank line.

Sample Input

2
2
10 10
9000 10
3
14 23 0
0 14 0
1000 9500 14

Sample Output

Scenario #1:
You have officially been pimped for only $30

Scenario #2:
You have officially been pimped for only $42

状压dp

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define INF 0x3f3f3f3f

using namespace std;

int T,N;
int a[16];
int job[16][16];
int dp[1<<15];

void init()
{
    a[1]=1;
    for(int i=2;i<16;i++){
        a[i]=a[i-1]*2;
    }
}

int get(int s,int j)
{
    int sum=job[j][j];
    for(int i=1;i<=N;i++){
        if((s&a[i])!=0){
            sum+=job[j][i];
        }
    }
    return sum;
}

void DP()
{
    memset(dp,INF,sizeof(dp));
    dp[0]=0;
    int len=1<<N;
    for(int i=0;i<len;i++){
        for(int j=1;j<=N;j++){
            if((i&a[j])==0){
                int to=i+a[j];
                int t=get(i,j);
                dp[to]=min(dp[to],dp[i]+t);
            }
        }
    }
}

int main()
{
    cin>>T;
    int counts=0;
    while(T--){
        counts++;
        init();
        cin>>N;
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++){
                cin>>job[i][j];
            }
        }
        DP();
        cout<<"Scenario #"<<counts<<':'<<endl;
        cout<<"You have officially been pimped for only $"<<dp[(1<<N)-1]<<endl;
        cout<<endl;
    }
}

内容概要:该研究通过在黑龙江省某示范村进行24小时实地测试,比较了燃煤炉具与自动/手动进料生物质炉具的污染物排放特征。结果显示,生物质炉具相比燃煤炉具显著降低了PM2.5、CO和SO2的排放(自动进料分别降低41.2%、54.3%、40.0%;手动进料降低35.3%、22.1%、20.0%),但NOx排放未降低甚至有所增加。研究还发现,经济性和便利性是影响生物质炉具推广的重要因素。该研究不仅提供了实际排放数据支持,还通过Python代码详细复现了排放特征比较、减排效果计算和结果可视化,进一步探讨了燃料性质、动态排放特征、碳平衡计算以及政策建议。 适合人群:从事环境科学研究的学者、政府环保部门工作人员、能源政策制定者、关注农村能源转型的社会人士。 使用场景及目标:①评估生物质炉具在农村地区的推广潜力;②为政策制定者提供科学依据,优化补贴政策;③帮助研究人员深入了解生物质炉具的排放特征和技术改进方向;④为企业研发更高效的生物质炉具提供参考。 其他说明:该研究通过大量数据分析和模拟,揭示了生物质炉具在实际应用中的优点和挑战,特别是NOx排放增加的问题。研究还提出了多项具体的技术改进方向和政策建议,如优化进料方式、提高热效率、建设本地颗粒厂等,为生物质炉具的广泛推广提供了可行路径。此外,研究还开发了一个智能政策建议生成系统,可以根据不同地区的特征定制化生成政策建议,为农村能源转型提供了有力支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值