Fight the Monster

CodeForces - 487A

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 HPa 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 HPATK and DEF of Master Yang.

The second line contains three integers HPM, ATKM, DEFM, separated by a space, denoting the HPATK 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

Input
1 2 1
1 100 1
1 100 100
Output
99
Input
100 100 100
1 1 1
1 1 1
Output
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的更多相关文章

随机推荐

  1. 史上最全python面试题详解(四)(附带详细答案(关注、持续更新))

    python高级进阶-网络编程和并发(?道题详解) 1.简述 OSI 七层协议. OSI是Open System Interconnection的缩写,意为开放式系统互联. OSI七层协议模型主要是: ...

  2. Android为TV端助力context转换类型

  3. 推荐一款MongoDB的客户端管理工具--nosqlbooster

    今天给大家推荐一款MongoDB的客户端工具--nosqlbooster,这个也是我工作中一直使用的连接管理MongoDB的工具.这个工具还有个曾用名--mongobooster.nosqlboost ...

  4. SQL Server非域(跨域)环境下镜像(Mirror)的搭建步骤及注意事项

    在实际的生产环境下,我们经常需要跨域进行数据备份,而创建Mirror是其中一个方案.但跨域创建Mirror要相对复杂的多,需要借助证书进行搭建. 下面我们将具体的步骤总结如下: 第一部分 创建证书 S ...

  5. 关于 MongoDB 与 SQL Server 通过本身自带工具实现数据快速迁移 及 注意事项 的探究

    背景介绍 随着业务的发展.需求的变化,促使我们追求使用不同类型的数据库,充分发挥其各自特性.如果决定采用新类型的数据库,就需要将既有的数据迁移到新的数据库中.在这类需求中,将SQL Server中的数 ...

  6. Apollo的Oracle适配改动

    这几天工作需要使用Apollo配置中心.Apollo唯一的依赖是MySQL数据库,然而公司只有Oracle数据库资源.这里有一个Oracle适配改动的分支,但是它是基于0.8.0版本的Apollo.看 ...

  7. 【原】Java学习笔记009 - 阶段测试

    package cn.temptation; public class Sample01 { public static void main(String[] args) { // 1.需求:打印如下 ...

  8. c/c++ 继承与多态 继承时如何改变个别成员的访问属性

    问题1:若类B以private的方式继承类A,但还想让类A的某些个别成员,保持public或者protected的访问属性,这时应该怎么办? 使用using,去改变访问属性. #include < ...

  9. python3 Queue(单向队列)

    创建队列 import queue q = queue.Queue() empty(如果队列为空,返回True) import queue q = queue.Queue() print(q.empt ...

  10. 网络威胁实时地图(CyberThread Real-time Map)

    今天跟大家分享一下网络威胁实时地图(CyberThread Real-time Map),从地图上可以看出目前网络威胁情况数据. 点击打开网络威胁实时地图 可以点击demo on/off来看演示.可以 ...