5435: 与怪物战斗

内存限制:256 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:3 通过:3

题目描述

    一个怪物正在攻击赛博世界!杨师傅,一个勇敢的人,要打败怪物。杨和怪物各有3个属性:生命值(HP),攻击力(ATK)和防御力(DEF)。



    在战斗中,怪物的HP每秒减少最大(0ATKY-DEFM),而杨的HP减少最大(0ATKM-DEFY),其中索引Y表示杨师傅,索引M表示怪物。两种降低同时发生 一旦怪物的HP≤0和杨师傅的HP>0同时发生,杨师傅获胜。



    杨师傅可以从赛伯兰的魔法商店购买属性:每HPh比特币,每ATK一个比特币,每DEFd比特币。



    现在杨师傅想知道他为了获胜可以花费多少比特币。

    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 1HP, 1ATK and 1DEF.
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.

输入格式

第一行包含三个整数 HPYATKYDEFY,用空格分隔,表示杨师傅的初始 HPATK DEF

第二行包含三个整数HPMATKMDEFM,用空格分隔,表示怪物的HPATKDEF

第三行包含三个整数had,用空格分隔,表示1HP1ATK1DEF的价格。

输入中的所有数字都是整数,介于 1 100 之间(含 1 100)。

输出格式

唯一的输出行应该包含一个整数,表示杨师傅为了获胜而应该花费的最低比特币。

输入

1 2 1

1 100 1

1 100 100

输出

99

输入

100 100 100

1 1 1

1 1 1

输出

0

注意

对于第一个样品,ATK DEF 的价格非常高。杨师傅可以买到99HP,那么他就可以打败剩下1HP的怪物了。

对于第二个样本,杨师傅足够强大,可以击败怪物,所以他不需要购买任何东西。

输入样例 复制

1 2 1
1 100 1
1 100 100

输出样例 复制

99