ZeptoLab Code Rush 2015 C. Om Nom and Candies
2015-04-05 13:25
423 查看
1.题目描述:点击打开链接
2.解题思路:本题是无限背包问题,根据重量的约束关系,直接暴力搜索。
3.代码:
2.解题思路:本题是无限背包问题,根据重量的约束关系,直接暴力搜索。
3.代码:
#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<algorithm> #include<string> #include<sstream> #include<set> #include<vector> #include<stack> #include<map> #include<queue> #include<deque> #include<cstdlib> #include<cstdio> #include<cstring> #include<cmath> #include<ctime> #include<functional> using namespace std; typedef long long ll; ll C, hr, wr, hb, wb; int main() { //freopen("t.txt", "r", stdin); while (cin >> C >> hr >> hb >> wr >> wb) { ll ans = 0; for (ll i = 0; i < 100000; i++) { if (i*wr <= C) ans = max(ans, i*hr + (C - wr*i) / wb*hb); if (i*wb <= C) ans = max(ans, i*hb + (C - wb*i) / wr*hr); } cout << ans << endl; } 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
- ZeptoLab Code Rush 2015---C. Om Nom and Candies
- ZeptoLab Code Rush 2015 B. Om Nom and Dark Park DFS
- ZeptoLab Code Rush 2015_B - Om Nom and Dark Park
- ZeptoLab Code Rush 2015 B. Om Nom and Dark Park
- Codeforces ZeptoLab Code Rush 2015 B. Om Nom and Dark Park DFS
- ZeptoLab Code Rush 2015 B. Om Nom and Dark Park
- ZeptoLab Code Rush 2015 B. Om Nom and Dark Park
- Codeforces - ZeptoLab Code Rush 2015 - D. Om Nom and Necklace:字符串
- Zepto Code Rush 2014 B - Om Nom and Spiders
- CF Zepto Code Rush 2014 B. Om Nom and Spiders
- ZeptoLab Code Rush 2015 C. Om Nom and Candies [ 数学 ]
- ZeptoLab Code Rush 2015 A. King of Thieves 暴力
- 【codeforces】 ZeptoLab Code Rush 2015 A,B,C,D,E题解
- ZeptoLab Code Rush 2015(树)
- 【codeforces】ZeptoLab Code Rush 2015 E 跳跃表? D kmp还不错的题
- ZeptoLab Code Rush 2015
- Codeforces ZeptoLab Code Rush 2015 A. King of Thieves