我是靠谱客的博主 唠叨白云,这篇文章主要介绍Codeforces Round #278 (Div. 1) A. Fight the Monster( 暴力),现在分享给大家,希望可以做个参考。

题目链接
题意:就是A,B俩人打架,每个人有血量HP,攻击力a,防御d,
然后有商店可以花钱买,血量,攻击力, 防御值. 问A打败B最少花多少钱。A能打败B就是B血量不大于0,A的血量大于0。
解答:题目给出的范围是0-100。首先我们加血是没什么用的,应该加攻击力或者防御力。然后我们枚举加攻击力和防御力的组合情况。结合题目的数据范围,我们知道防御最大也就是加到100,然后攻击力,我们可能的最大也就是200(比如我们的攻击力是0,对面防御100,他的血量100,我们只要200攻击力就OK了)

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#define CF #ifndef CF #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #else #include<bits/stdc++.h> #endif // CF using namespace std; #define LL long long #define pb push_back #define X first #define Y second #define cl(a,b) memset(a,b,sizeof(a)) typedef pair<long long ,long long > P; const int maxn=100005; const LL inf=1LL<<50; const LL mod=1e9+7; int main(){ int h1,h2,a1,a2,d1,d2,h,d,a; cin>>h1>>a1>>d1>>h2>>a2>>d2>>h>>a>>d; LL ans=inf; for(int i=0;i<=200;i++)if(a1+i>d2){//i是加攻击 for(int j=0;j<=100;j++){//加防御 int A=a1+i-d2;//A对B每秒造成的伤害 int B=a2-(d1+j);//B对A 每秒造成的伤害 int x=(h2+A-1)/A;//B血量没了需要的时间 int y=h1; y-=x*B; if(y<=0){ y=-y+1; ans=min(ans,y*h*1LL+i*a+j*d); } else ans=min(ans,i*a+j*d*1LL); } } cout<<ans<<endl; return 0; }

最后

以上就是唠叨白云最近收集整理的关于Codeforces Round #278 (Div. 1) A. Fight the Monster( 暴力)的全部内容,更多相关Codeforces内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(81)

评论列表共有 0 条评论

立即
投稿
返回
顶部