CF Om Nom and Candies
2015-05-17 21:12
387 查看
分析:输入总重量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; }
相关文章推荐
- ZeptoLab Code Rush 2015---C. Om Nom and Candies
- C. Om Nom and Candies(ZeptoLab Code Rush 2015)
- ZeptoLab Code Rush 2015 C题Om Nom and Candies
- CF 526C Om Nom and Candies
- ZeptoLab Code Rush 2015 C. Om Nom and Candies 暴力
- Codeforces 526C - Om Nom and Candies
- Codeforces 526C - Om Nom and Candies(贪心)
- Codeforces 526C - Om Nom and Candies (贪心 + 思维)
- codeforces 526 c Om Nom and Candies 剩余系
- Codeforces 526C - Om Nom and Candies(贪心,暴力)
- 526C - Om Nom and Candies
- 【Henu ACM Round#19 E】 Om Nom and Candies
- Codeforces 526C Om Nom and Candies
- ZeptoLab Code Rush 2015 C. Om Nom and Candies
- CF Om Nom and Dark Park
- B. Inna and New Matrix of Candies
- 判断s各个前缀是否是 ABABA…ABA的形式 KMP Codeforces 526D - Om Nom and Necklace
- ZeptoLab Code Rush 2015_B - Om Nom and Dark Park
- CodeForces 436C (Dungeons and Candies)
- ZeptoLab Code Rush 2015 B. Om Nom and Dark Park