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\n", &t);
while(t--)
{
scanf("%d%d%d%d%d%d", &a, &b, &c, &ab, &bc, &ac);
int ans = ;
//cout << "ab bc ac\n";
for (int i=; i<=a; ++i) //ab
{
for (int j=; j<=b-i; ++j) //bc
{
int tt;
if (a-i > c-j) tt = c-j; //ac
else tt = a-i;
if (tt < ) continue;
//cout << tt << "==\n";
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\n", ans);
}
return ;
}

UVALive 5840 数学题的更多相关文章

  1. Gym 101194H / UVALive 7904 - Great Cells - [数学题+快速幂][2016 EC-Final Problem H]

    题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?opti ...

  2. UVALive 6084 Happy Camper(数学题)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  3. UVALive - 4108 SKYLINE[线段树]

    UVALive - 4108 SKYLINE Time Limit: 3000MS     64bit IO Format: %lld & %llu Submit Status uDebug ...

  4. UVALive - 3942 Remember the Word[树状数组]

    UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...

  5. UVALive - 3942 Remember the Word[Trie DP]

    UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...

  6. ytu 2558: 游起来吧!超妹!(水题,趣味数学题)

    2558: 游起来吧!超妹! Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 7  Solved: 3[Submit][Status][Web Board ...

  7. sdut 2416:Fruit Ninja II(第三届山东省省赛原题,数学题)

    Fruit Ninja II Time Limit: 5000MS Memory limit: 65536K 题目描述 Have you ever played a popular game name ...

  8. 思维 UVALive 3708 Graveyard

    题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...

  9. UVALive 6145 Version Controlled IDE(可持久化treap、rope)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

随机推荐

  1. tensorflow mnist 给一张手写字辨别

    https://www.jianshu.com/p/db2afc0b0334 https://blog.csdn.net/xxzhangx/article/details/54563574

  2. [c/c++]指针(4)

    现在讲一下指针的主要用途和常见错误. [用途] 1.用作形参 首先,常见新手写交换函数: void swap(int a,int b){ int t = a; a = b; b = t; } 主函数里 ...

  3. Linux查看网卡带宽的两个命令

    1.ethtool ethtool 网络接口名 #ethtool em4 Settings for em4: Supported ports: [ TP ] Supported link modes: ...

  4. Spring的面向切面

    Spring的面向切面 在应用开发中,有很多类似日志.安全和事务管理的功能.这些功能都有一个共同点,那就是很多个对象都需要这些功能.复用这些通用的功能的最简单的方法就是继承或者委托.但是当应用规模达到 ...

  5. centos6搭建redis集群搭建(单机多节点)

    一.安装redis 1.安装gcc环境 yum install gcc-c++ 2.下载源码包并解压 wget http://download.redis.io/releases/redis-3.2. ...

  6. kylin从入门到实战:实际案例

    版权申明:转载请注明出处.文章来源:http://bigdataer.net/?p=308 排版乱?请移步原文获得更好的阅读体验 前面两篇文章已经介绍了kylin的相关概念以及cube的一些原理,这篇 ...

  7. Mac升级到EI Captain之后pip install 无法使用问题

    错误log: creating /System/Library/Frameworks/Python.framework/Versions/2.7/share error: could not crea ...

  8. Linux内核的五大模块

    Linux内核的五大模块 (转自)https://blog.csdn.net/huangjingbin/article/details/19396235 Linux内核的五大模块 1.进程调度模块 2 ...

  9. c assert 用法

    #include <stdio.h> /* printf */ #include <assert.h> /* assert */ void print_number(int* ...

  10. Nginx 多重条件判断

    server{ listen 80; server_name xxx.com; index index.html index.htm index.php admin.php; root /home/w ...