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的更多相关文章
随机推荐
- 左侧固定,右侧自适应的布局方式理解margin负值理论
一.浮动布局 1.先让固定宽度的div浮动!使其脱离文档流.2.margin-left的值等于固定div的宽度相等. .aside{ float: left; width: 200px; backgr ...
- 42.Odoo产品分析 (四) – 工具板块(10) – 问卷(2)
查看Odoo产品分析系列--目录 接上一篇Odoo产品分析 (四) – 工具板块(10) – 问卷(1) 4 页面 即问卷,点开一项查看: 可以看出,网页就是问卷本身的子目录,其中指明了该目录包括哪 ...
- ASP.NET没有魔法——ASP.NET MVC IoC代码篇
上一篇文章主要以文字的形式介绍了IoC及其在ASP.NET MVC中的使用,本章将从以下几点介绍如何使用代码在ASP.NET MVC中实现依赖注入: ● AutoFac及安装 ● 容器的创建 ● 创建 ...
- shell脚本批量ssh登陆主机并执行命令
shell脚本批量ssh登陆主机并执行命令 今天在客户现场遇到了这个问题,客户没有管理工具,无法批量登陆主机下发命令,几个个C段啊,让我一个一个登陆,.................. 所以写了个s ...
- MySQL的自动提交模式
默认情况下, MySQL启用自动提交模式(变量autocommit为ON).这意味着, 只要你执行DML操作的语句,MySQL会立即隐式提交事务(Implicit Commit).这个跟SQL S ...
- .net向文件写入字符串流内存溢出的问题
字符串过大导致抛出异常: exceptopm of type 'system.outOfmemoryexception' was thrown 解决方法:逐块写入可以避免这个问题
- tomcat设置开机启动
一.windows 1. 下载tomcat 2. 进入bin目录,查看是否存在service.dat,如果没有自行创建 3. 打开cmd,进入tomcat>bin目录 说明:用法: servic ...
- 用Angular部署Cesium
用到的集成开发环境是WebStrom,Cesium版本是1.50.0,Angular版本是6.2.4 1.首先我们安装cesium,在webstorm中的Termianl中输入 npm instal ...
- scheme实现最基本的自然数下的运算
版权申明:本文为博主窗户(Colin Cai)原创,欢迎转帖.如要转贴,必须注明原文网址 http://www.cnblogs.com/Colin-Cai/p/9123363.html 作者:窗户 Q ...
- 新数据革命: 开源C#图形化爬虫引擎Hawk5发布
https://ferventdesert.github.io/Hawk/ Hawk是一款由沙漠之鹰历时五年个人业余时间开发的,开源图形化爬虫和数据清洗工具,GitHub Star超过2k+,前几代版 ...