zoukankan      html  css  js  c++  java
  • UVALive 5840 数学题

    DES:给出三种材料A,B,C每种的个数。然后组合AB,BC,AC的利润。问能获得的最大利润是多少。

    开始一点思路都没有。然后发现可以枚举其中两种的个数。那么最后一种就确定了。还是感觉很机智。

    #include<stdio.h>
    #include<iostream>
    #include<string.h>
    using namespace std;
    
    int main()
    {
        int t;
        int ab, bc, ac;
        int a, b, c;
        scanf("%d
    ", &t);
        while(t--)
        {
            scanf("%d%d%d%d%d%d", &a, &b, &c, &ab, &bc, &ac);
            int ans = 0;
            //cout << "ab bc ac
    ";
            for (int i=0; i<=a; ++i) //ab
            {
                for (int j=0; j<=b-i; ++j) //bc
                {
                    int tt;
                    if (a-i > c-j) tt = c-j;  //ac
                    else tt = a-i;
                    if (tt < 0) continue;
                    //cout << tt << "==
    ";
                    if (i+j>b || i+tt>a || j+tt>c) continue;
                    int ttt = ab*i + j*bc + tt*ac;
                    //cout << i << "==" << j << "==" << tt << endl;
                    //cout << ttt << endl;
                    if (ans < ttt) ans = ttt;
                }
            }
            printf("%d
    ", ans);
        }
        return 0;
    }
    View Code
  • 相关阅读:
    hdoj_1556Color the ball
    wchar_t与char转换(总结)
    算法艺术——网络最大流
    poj_3268Silver Cow Party
    poj_2352Stars
    BellmanFord模板
    saas模式
    什么是管道
    什么是CMMI
    saas模式
  • 原文地址:https://www.cnblogs.com/icode-girl/p/4731218.html
Copyright © 2011-2022 走看看