Fight the Monster
            time limit per test            

1 second

                                  memory limit per test      

256 megabytes

                                  input                              

standard input   

                                  output                            

standard output

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 bymax(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.

Sample test(s)
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.

打DIV1真是从头卡落未,差点爆0 , 最后还是过了 。

题意很容易懂。

然后我暴力枚举 3 个变量 初始值 ~ 200 。 过了小数据, 然后被hack 了 。

其实不然 , 因为monster 各个属性最大都是100。

那么Yang的攻击力最多枚举到201就可以秒了monster 。

防御力最多枚举到101就可保证自己滴血不伤 。

然而血量是可以好大的 。

我直接从初始值暴力找上去第一个合法的血量 。

这样都能过,可能数据是弱了。后来想过弄一个10的几次方二分快点。

其实也不用 。 你已经确定了2个值 ,直接通过公式就可以得出血量的下界了。

O(1)时间解决。

3层暴力代码:

#include <bits/stdc++.h>
using namespace std; typedef long long LL; const int N = ;
const int inf = 1e9 + ; int a ,b , c , hp1 , ac1 , of1, hp2 , ac2 , of2 ; bool check( int hp , int ac , int of ){
if( ac - of2 <= ) return false ; if( ac2 - of <= ) return true ;
if( ceil( (double) hp / ( ac2 - of ) ) > ceil( (double) hp2 / ( ac - of2 ) ) ) return true ;
return false ;
}
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif // LOCAL
ios::sync_with_stdio(false);
while( cin >> hp1 >> ac1 >> of1 >> hp2 >> ac2 >> of2 >> a >> b >> c ){
int ans = inf ;
if( of1 >= ac2 ) { if( ac1 > of2 ) cout << '' << endl ; else cout << ( of2 + - ac1 ) * b << endl; break ; }
for( int i = max( ac1 , of2 + ) ; i <= ; ++i ) {
for( int j = of1 ; j <= ac2 + ; ++j ){
for( int k = hp1 ; ; ++k ){
if( check( k , i , j ) ) {
ans = min( ans , ( k - hp1 ) * a + ( i - ac1 ) * b + ( j - of1 ) * c ) ; break ;
}
}
}
}
cout << ans << endl ;
}
return ;
}

Codeforces 488C Fight the Monster的更多相关文章

  1. codeforces 487a//Fight the Monster// Codeforces Round #278(Div. 1)

    题意:打怪兽.可增加自己的属性,怎样在能打倒怪兽的情况下花费最少? 这题关键要找好二分的量.一开始我觉得,只要攻击到101,防御到100,就能必胜,于是我对自己的三个属性的和二分(0到201),内部三 ...

  2. Codeforces Round #278 (Div. 1) A. Fight the Monster 暴力

    A. Fight the Monster Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/487/ ...

  3. codeforces 487A A. Fight the Monster(二分)

    题目链接: A. Fight the Monster time limit per test 1 second memory limit per test 256 megabytes input st ...

  4. Codeforces 954D Fight Against Traffic(BFS 最短路)

    题目链接:Fight Against Traffic 题意:有n个点个m条双向边,现在给出两个点S和T并要增加一条边,问增加一条边且S和T之间距离不变短的情况有几种? 题解:首先dfs求一下S到其他点 ...

  5. Codeforces - 102222H - Fight Against Monsters - 贪心

    https://codeforc.es/gym/102222/problem/H 题意:有一堆怪兽,怪兽有HP和ATK.你有一个英雄,英雄每次先被所有怪兽打,然后打其中一个怪兽.打的伤害递增,第一次1 ...

  6. Codeforces 918C/917A - The Monster

    传送门:http://codeforces.com/contest/918/problem/C 一个括弧串由字符‘(’和‘)’组成.一个正确的串可被递归地定义,定义如下: ①空串e是一个正确的串: ② ...

  7. 【codeforces 787A】The Monster

    [题目链接]:http://codeforces.com/contest/787/problem/A [题意] 把b一直加a->得到x 把d一直加c->得到y 然后问你x和y可不可能有相同 ...

  8. Codeforces 1296D - Fight with Monsters

    题目大意: n 只怪兽,每只的血量为 h[i] ,你的攻击力为 a ,你的对手攻击力为 b 打每只怪兽时,都是你先出手,然后你的对手出手,这样轮流攻击 如果是你给予了怪兽最后一击,你就能得到一分 你还 ...

  9. Codeforces Round #278 (Div. 2)

    题目链接:http://codeforces.com/contest/488 A. Giga Tower Giga Tower is the tallest and deepest building ...

随机推荐

  1. List集合--Vector子类

    Vector子类 Vector是一个原始古老的程序类,这个类是在JDK1.0的时候就提供的,而后到了JDK1.2的时候,由于有一部分开发者已经习惯于使用Vector,并且许多的系统类也是基于Vecto ...

  2. 调用Consul服务(消费服务)

    调用Consul服务(消费服务) 依赖项 在spring-cloud-consul-client项目中添加依赖项,POM文件内容中添加如下依赖项: <dependency> <gro ...

  3. PHP语言基础练习20191024

    <style>*{font-size: 30px;}</style> //传地址  &<?phpfunction sum($a,&$b){ $c=$a+$ ...

  4. L2Dwidget

    只需要在[页首html代码]中引入L2Dwidget.js即可.<!-- 右下角live2d效果 --> <script src="https://eqcn.ajz.mie ...

  5. MyEclipse2017搭建android开发环境

    1 安装MyEclipse2017cli7; 2 准备安装ADT插件和 Android SDK 开发包;比如:ADT-24.0.2 android-sdk_r24.4.1-windows; 工具栏点击 ...

  6. 【记录】linux docker 安装 tomcat

    前言:首先linux需要先安装docker,具体步骤可以参考博主之前博客,也可自行百度. 话不多说,开始安装tomcat: 通过docker安装tomcat docker pull tomcat:8. ...

  7. MVC默认提供了一个异常过滤器 HandleErrorAttribte特性

    这一篇记录MVC默认提供了一个异常过滤器 HandleErrorAttribte,下一篇介绍自定义异常过滤特性. 参考引用:https://www.cnblogs.com/TomXu/archive/ ...

  8. css 多行省略号兼容移动端

    浏览器兼容css样式 -webkit-line-clamp: ; display: -webkit-box; overflow: hidden; text-overflow: ellipsis; te ...

  9. springboot配置redis+jedis,支持基础redis,并实现jedis GEO地图功能

    Springboot配置redis+jedis,已在项目中测试并成功运行,支持基础redis操作,并通过jedis做了redis GEO地图的java实现,GEO支持存储地理位置信息来实现诸如附近的人 ...

  10. 阿里云安装Cloudera Manager(草稿)

    选择三台同一局域网的阿里云服务器 最初使用阿里云.京东云.百度云的三台不同的服务器,遇到一些问题,没有解决,公网速度也没有保障,还是选择同一局域网的服务器吧 CM有三种不同的安装方式: 通过 Clou ...