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. 20145225唐振远《网络对抗》Exp4 恶意代码分析

    20145225唐振远<网络对抗>Exp4 恶意代码分析 基础问题回答 如果在工作中怀疑一台主机上有恶意代码,但只是猜想,所有想监控下系统一天天的到底在干些什么.请设计下你想监控的操作有哪 ...

  2. bzoj 4033 树上染色 - 树形动态规划

    有一棵点数为N的树,树边有边权.给你一个在0~N之内的正整数K,你要在这棵树中选择K个点,将其染成黑 色,并将其他的N-K个点染成白色.将所有点染色后,你会获得黑点两两之间的距离加上白点两两之间距离的 ...

  3. jz2440-linux3.4.2-kernel移植【学习笔记】【原创】

    平台:jz2440 作者:庄泽彬(欢迎转载,请注明作者) 说明:韦东山二期视频学习笔记 交叉编译工具:arm-linux-gcc (GCC)4.3.2 linux:linu3.4.2 PC环境:ubu ...

  4. ubuntu下交叉编译imagemagick

    环境:ubuntu16.04 交叉编译器版本号:4.8.3 在编译之前要编译以下其依赖的软件或库:freetype,libpng,libxml2,libtiff,libjpeg,zlib,graphv ...

  5. OJ上 编译器 G++和C++的区别

    原文 :http://blog.csdn.net/febr2/article/details/52068357 编译时的差异: 编译器优化不同: 举个栗子: ①: a++ ②: ++a 从标准C的角度 ...

  6. 用caffe进行图片检索

    1.图片的处理 输入:将自己的图像转换成caffe需要的格式要求:lmdb 或者 leveldb 格式 这里caffe有自己提供的脚本:create_minst.sh 转换训练图片和验证图片的格式,运 ...

  7. 《剑指offer》第一题(重载赋值运算符)

    //重载赋值运算符 #include <iostream> #include <cstring> using namespace std; class CMystring { ...

  8. node 循序渐进

    1. 执行 node helloworld.js 2. http  服务器 建 server.js 文件 -  node server.js  跑起来 -  浏览器访问  http://localho ...

  9. tp3.x和tp 5的区别

    由于TP5.0是一个全新的颠覆重构版本,所以现在面试很多面试官喜欢问TP3.2和TP5之间的区别,那他们之间到底有哪些区别呢?一.目录  TP5目录 二.需要摒弃的 3.X 旧思想 模型的变动     ...

  10. 使用cocos创建的项目,如何进行源码调试?

    环境cocos3.10,里面包含了cocos2dx 3.10引擎.但是用cocos创建出来的项目,使用的lib和dll是文件夹Cocos\Cocos2d-x\cocos2d-x-3.10\prebui ...