Fight the Monster题解报告
来源:互联网 发布:如采用电爆网络起爆 编辑:程序博客网 时间:2024/05/09 20:38
http://codeforces.com/problemset/problem/487/A
题目大致意思是:Yang打怪兽,血量HP,攻击力ATK,防御力DEF。用HPY, ATKY, DEFY,表示Yang的属性,HPM, ATKM, DEFM表示怪兽的属性。每秒钟怪兽的血减少max(0, ATKY - DEFM),Yang的血减少max(0, ATKM - DEFY)。当怪兽的血小于等于0,Yang的血大于0时,Yang赢。Yang的三种属性都可以购买,单价分别为h,a,d,求保证Yang胜利,最少花费多少钱。
思路:枚举。可以得到攻击力的上界是max(0,dm+hm-ay),防御力的上界是max(0,am-dy),血量则可以通过公式得到。怪兽和人的血量减少每一秒都是相同的,所以先得到怪兽死亡需要的时间,若有余数,时间加1,然后再求得人最少需要的血量。最后比较得出最少的花费
上代码
#include <iostream>
using namespace std;
int main()
{
int hy,ay,dy,hm,am,dm,h,a,d;
cin>>hy>>ay>>dy>>hm>>am>>dm>>h>>a>>d;
int i,j,k,ans=100000,sum,tmp;
for(j=0;j<=max(0,dm+hm-ay);j++)
{
for(k=0;k<=max(0,am-dy);k++)
{
if(ay+j-dm<=0)
break;
if(ay+j-dm>0)
{
tmp=hm/(ay+j-dm);
if(hm%(ay+j-dm)!=0)
tmp++;
i=max(0,tmp*max(0,(am-dy-k))-hy+1);
}
sum=i*h+j*a+k*d;
if(ans>sum)
ans=sum;
}
}
cout<<ans<<endl;
return 0;
}
- Fight the Monster题解报告
- CF488C Fight the Monster
- CF_487A Fight the Monster(二分)
- codeforces 487A Fight the Monster
- 【Codeforces】 487A Fight the Monster
- CodeForces 487A Fight the Monster
- codeforces #487A# Fight the Monster(枚举)
- Codeforces 487A Fight the Monster(暴力)
- Codeforces 487A Fight the Monster
- Codeforces Round #278 (Div. 2) 488C.Fight the Monster
- Codeforces 488 C. Fight the Monster(模拟)
- Codeforces Round #278 (Div. 2) C. Fight the Monster(暴力)
- codeforces 488C Fight the Monster(枚举)
- codeforces 487 A Fight the Monster 暴力枚举
- Codeforces 488C Fight the Monster【二分+枚举】
- CodeForces 488 C.Fight the Monster(枚举)
- Codeforces Round #278 (Div. 2) C. Fight the Monster 二分+枚举
- Codeforces Round #278 (Div. 1) A. Fight the Monster( 暴力)
- Windows下查看CPU是多少位的
- 去掉UIWebView底部的黑条
- 安静的午夜你在祈祷什么
- frameset、frame、noframes和iframe的区别
- SMART 法则
- Fight the Monster题解报告
- startActivityForResult、setResult、onActivityForResult
- rails 文档在线预览方案
- 人脸检测——OpenCV的分类器的haar特征数据
- android中所有颜色代码
- windows socket 流式套接字笔记
- 九九乘方表/数组排序/反向输出字符串
- 2014科技大佬悲喜录:有人锒铛入狱有人睡不着觉
- android 反编译