CF Om Nom and Candies
来源:互联网 发布:mac装win7怎么进入 编辑:程序博客网 时间:2024/06/06 21:45
分析:输入总重量c,红糖幸福值hr,蓝糖幸福值hb,红糖重wr,蓝糖重wb.输出最大的幸福值。直接暴力就可以了。为了防止时间超限,限制它的循环次数。
# include <stdio.h> int main() { __int64 c,hr,hb,wr,wb,r,b,i,j,max=0,time=10000000; scanf("%I64d%I64d%I64d%I64d%I64d",&c,&hr,&hb,&wr,&wb); r=c/wr;//最多取r个red candy b=c/wb;//最多取b个blue candy for(i=0;i<=r&&i<=time;i++) { j=(c-i*wr)/wb;//取i个红糖最多取j个蓝糖 if(i*hr+j*hb>max) max=i*hr+j*hb; } for(j=0;j<=b&&j<=time;j++) { i=(c-j*wb)/wr;//取j个蓝糖最多取i个红糖 if(i*hr+j*hb>max) max=i*hr+j*hb; } printf("%I64d\n",max); return 0; }
0 0
- CF Om Nom and Candies
- CF 526C Om Nom and Candies
- 526C - Om Nom and Candies
- Codeforces 526C Om Nom and Candies
- Codeforces 526C - Om Nom and Candies
- CF Om Nom and Dark Park
- CF 526D Om Nom and Necklace
- ZeptoLab Code Rush 2015 C. Om Nom and Candies
- ZeptoLab Code Rush 2015---C. Om Nom and Candies
- Codeforces 526C - Om Nom and Candies (贪心 + 思维)
- ZeptoLab Code Rush 2015 C题Om Nom and Candies
- codeforces 526 c Om Nom and Candies 剩余系
- C. Om Nom and Candies(ZeptoLab Code Rush 2015)
- Codeforces 526C - Om Nom and Candies(贪心,暴力)
- Codeforces 526C Om Nom and Candies 完全背包
- CF Zepto Code Rush 2014 B. Om Nom and Spiders
- Om Nom and Dark Park
- Om Nom and Dark Park
- Wireshark基本介绍和学习TCP三次握手
- IOS atomic与nonatomic,assign,copy与retain的定义和区别
- tomcat相关【各种参数说明以及内存配置优化需要整理】
- 关于eclipse中怎么关联java的源码 和jar包的源码
- symfony2安装第三方bundle(不通过composer)
- CF Om Nom and Candies
- 详解内联元素和块元素
- hdoj 5230 ZCC loves hacking
- other linker flags objc配置
- 配置文件 DecodingRefreshType 参数讲解
- 【leetcode】Combination Sum
- 1 ubuntu14.04无线上网问题
- 五、单例模式
- LintCode-矩阵归零