首页 > 其他 > 详细

Codeforces Round #278 (Div. 2) c

时间:2014-11-25 14:38:25      阅读:257      评论:0      收藏:0      [点我收藏+]
/**
 * @brief Codeforces Round #278 (Div. 2) c
 * @file c.c
 * @author 面码
 * @created 2014/11/25 14:15
 * @edited  2014/11/25 14:15
 * @type brute
 *
 */
#include <stdio.h>

#define max(a, b)  ((a) > (b) ? (a) : (b))
#define min(a, b)  ((a) > (b) ? (b) : (a)) 
#define abs(a)     ((a) >  0  ? (a) : (0 - (a)))

int hpY, atkY, defY;
int hpM, atkM, defM;
int hp,  atk,  def;
int hpC, atkC, defC;

int main()
{
    int min_cost, curr_cost;
    int decY, decM;
    int round;
#ifdef DEBUG
    freopen("./in",  "r", stdin);
    freopen("./out", "w", stdout);
#endif
    scanf("%d%d%d", &hpY, &atkY, &defY);  
    scanf("%d%d%d", &hpM, &atkM, &defM);  
    scanf("%d%d%d", &hp,  &atk,  &def);  
    min_cost = 0x7fffffff;
    for(atkC = 0; atkC <= 200; atkC++)
            for(defC = 0; defC <= 200; defC++){
                decY = atkM - (defY + defC);
                decM = (atkY + atkC) - defM;
    
                if(decM <= 0)           /*can‘t kill monster*/
                    continue;

                if(decY > 0){
                    round =  hpM/decM + (hpM%decM ? 1: 0);
                    hpC = hpY - decY*round;
                    if(hpC <= 0)
                        hpC = abs(hpC) + 1;
                    else
                        hpC = 0;
                }else{
                        hpC = 0;            /*need not buy hp*/
                }
                curr_cost = hp*hpC + atk*atkC + def*defC;
                min_cost = min(curr_cost, min_cost);
            }
    printf("%d\n", min_cost);
    return 0;
}


Codeforces Round #278 (Div. 2) c

原文:http://my.oschina.net/u/572632/blog/348523

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!