codeforces487A
Fight the Monster
A monster is attacking the Cyberland!
Master Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF).
During the battle, every second the monster's HP decrease by max(0, ATKY - DEFM), while Yang's HP decreases by max(0, ATKM - DEFY), where index Y denotes Master Yang and index M denotes monster. Both decreases happen simultaneously Once monster's HP ≤ 0 and the same time Master Yang's HP > 0, Master Yang wins.
Master Yang can buy attributes from the magic shop of Cyberland: h bitcoins per HP, a bitcoins per ATK, and d bitcoins per DEF.
Now Master Yang wants to know the minimum number of bitcoins he can spend in order to win.
Input
The first line contains three integers HPY, ATKY, DEFY, separated by a space, denoting the initial HP, ATK and DEF of Master Yang.
The second line contains three integers HPM, ATKM, DEFM, separated by a space, denoting the HP, ATK and DEF of the monster.
The third line contains three integers h, a, d, separated by a space, denoting the price of 1 HP, 1 ATK and 1 DEF.
All numbers in input are integer and lie between 1 and 100 inclusively.
Output
The only output line should contain an integer, denoting the minimum bitcoins Master Yang should spend in order to win.
Examples
1 2 1
1 100 1
1 100 100
99
100 100 100
1 1 1
1 1 1
0
Note
For the first sample, prices for ATK and DEF are extremely high. Master Yang can buy 99 HP, then he can beat the monster with 1 HP left.
For the second sample, Master Yang is strong enough to beat the monster, so he doesn't need to buy anything.
sol:一开始想了好几个SB贪心都被自己否定掉了,猛然发现数据范围小的不像话,暴力枚举n2即可
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int inf=0x3f3f3f3f;
struct Record
{
int Hp,Atk,Def;
}a,b,Buy;
int main()
{
int i,j,k,ans=inf;
R(a.Hp); R(a.Atk); R(a.Def);
R(b.Hp); R(b.Atk); R(b.Def);
R(Buy.Hp); R(Buy.Atk); R(Buy.Def);
for(i=;i<=b.Hp;i++)//几回合干掉怪兽
{
int ATK=(b.Hp/i+(bool)(b.Hp%i))+b.Def;
for(j=;j<=b.Atk;j++)//增加几点防御
{
int DEF=a.Def+j;
int Sum=max(ATK-a.Atk,)*Buy.Atk+j*Buy.Def;
int Hp=max(b.Atk-DEF,)*i+;
ans=min(ans,Sum+max(Hp-a.Hp,)*Buy.Hp);
}
}
Wl(ans);
return ;
}
/*
Input
1 2 1
1 100 1
1 100 100
Output
99 Input
100 100 100
1 1 1
1 1 1
Output
0
*/
codeforces487A的更多相关文章
随机推荐
- jsp内置对象的作用范围
内置对象的作用范围是指每个内置对象的某个实例在多长时间和多大的范围中有效,即在什么样的范围内可以有效地访问同一个对象实例. 在javax.servlet.jsp.PageContext的类中定义了4个 ...
- alfs学习笔记-安装和使用blfs工具
我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! 一名linux爱好者,记录构建Beyond Linux From Scratch的过程 经博客园-骏马金龙前辈介绍,开始接触学习 ...
- thymeleaf的配置
1.在springboto项目中使用thymeleaf标签,必须先添加依赖,如下. <dependency> <groupId>org.springframework.boot ...
- linux中Samba服务器的配置
Samba简介 Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服务器及客户端程序构成.SMB(Server Messages Block,信息服务块)是一种在局域网上共享文件 ...
- win10 家庭版不支持gpedit.msc的解决办法
win10 家庭版不支持gpedit.msc的解决办法 1.建立一个批处理文件内容如下: @echo off pushd "%~dp0" dir /b %systemroot%\W ...
- MySQL常用字符串函数
字符串函数 是最常用的的一种函数,在一个具体应用中通常会综合几个甚至几类函数来实现相应的应用: 1.LOWER(column|str):将字符串参数值转换为全小写字母后返回 mysql> sel ...
- Java - String 的字面量、常量池、构造函数和intern()函数
一.内存中的 String 对象 Java 的堆和栈 对于基本数据类型变量和对象的引用,也就是局部变量表属于栈内存: 而通过 new 关键字和 constructor 创建的对象存放在堆内存: 直接的 ...
- luajit官方性能优化指南和注解
luajit是目前最快的脚本语言之一,不过深入使用就很快会发现,要把这个语言用到像宣称那样高性能,并不是那么容易.实际使用的时候往往会发现,刚开始写的一些小test case性能非常好,经常毫秒级就算 ...
- Linux垃圾清理
一.删除缓存 1,非常有用的清理命令:sudo apt-get autoclean 清理旧版本的软件缓存sudo apt-get clean ...
- wxPython树控件
1.树控件 树(tree)是一种通过层次结构展示信息的控件,如下图所示是树控件示例,左窗口中是树控件,在wxPython中树控件类是wx.TreeCtrl. wx.TreeCtrl中一个常用的方法有: ...