hdu 4091 Zombie’s Treasure Chest
来源:互联网 发布:安卓手机编程入门 编辑:程序博客网 时间:2024/05/13 19:53
需要仔细体会s1和s2都很小的时候,其枚举量为什么是s1+s2
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int t,kase;
int main()
{
scanf("%d",&t);
kase=1;
while(t--)
{
long long n,s1,v1,s2,v2;
long long ans=0;
cin>>n>>s1>>v1>>s2>>v2;
printf("Case #%d: ",kase++);
if(s1 > s2)//体积小的去前边
{
swap(s1, s2);
swap(v1, v2);
}
if(n / s2 >= 65536)
{
for(long long i = 0; i <= s1; i++)
{
ans = max(ans, v2*i + (n-s2*i)/s1*v1);
}
for(long long i = 0; i <= s2; i++)
{
ans = max(ans, v1*i + (n-s1*i)/s2*v2);
}
}
else // s2 is large
{
for(long long i = 0; s2*i <= n; i++)
ans = max(ans, v2*i + (n-s2*i)/s1*v1);
}
printf("%lld\n",ans);
}
return 0;
}
- HDU 4091--Zombie’s Treasure Chest
- hdu 4091 Zombie’s Treasure Chest
- HDU 4091 - Zombie’s Treasure Chest
- hdu 4091 Zombie’s Treasure Chest
- HDU-4091 Zombie’s Treasure Chest
- HDU 4091 Zombie’s Treasure Chest (每日一题)
- hdu(4091)Zombie’s Treasure Chest(贪心+背包)
- hdu 4091 Zombie’s Treasure Chest 贪心+枚举
- HDU 4091 Zombie’s Treasure Chest (不错的数论题)
- HDU 4091Zombie’s Treasure Chest(贪心+枚举)
- HDU 4091Zombie’s Treasure Chest (数学加暴力)
- HDU—— 4091 Zombie’s Treasure Chest
- HDU 4091 Zombie’s Treasure Chest(贪心+枚举)
- HDU4091 Zombie’s Treasure Chest
- hdu4091 Zombie’s Treasure Chest
- UVa12325 - Zombie's Treasure Chest
- 12325 Zombie's Treasure Chest
- 12325 - Zombie's Treasure Chest.
- 3Sum
- SAX方式解析XML文档
- android_framework日记2-代码下载&编译
- apache、mysql安装过程遇到的问题
- 雅虎天气API使用笔记
- hdu 4091 Zombie’s Treasure Chest
- Oracle学习笔记(5)-----------单行函数
- Qt静态库的下载和安装配置
- getErrnoString.c
- WPF 入门 -- Layout:Grid, DockPanel and StackPanel
- UIPickerView的使用
- Stroustrup专访:畅想C++17
- jQuery Callbacks应用关键点
- 安卓间隔一定时间之后动态更新视图【代码实现】