Codeforces Round #635 (Div. 2) B. Kana and Dragon Quest game

Codeforces Round #635 (Div. 2)的其他题解请点这里

B. Kana and Dragon Quest game

题目大意:
有一条龙有x点生命值
现在你要打到他
你有两个技能
1.使龙的血量变成
x = ⌊ x / 2 ⌋ + 10 x=\left \lfloor x/2\right \rfloor +10 x=x/2+10
2.使龙的血量变成
x = x − 10 x=x-10 x=x10
但是每个技能都有使用次数,分别为n, m


思路:
当 x < ⌊ x / 2 ⌋ + 10 时 当 x<\left \lfloor x/2\right \rfloor +10时 x<x/2+10
使用1技能效果更好,所以我们贪心,竟可能的使用1技能
当1技能效果不如2技能时我们就改用2技能

AC代码:

#include<cstdio>
#include<iostream>
#include<cstring>
#include<map>
#include<random>
#include<algorithm>
#define ll long long 
using namespace std;
const int maxn = 1e6 + 7;
int n, m;
int main() {
	int T;
	scanf("%d", &T);
	while (T--) {
		int x, n, m;
		scanf("%d %d %d", &x, &n, &m);
		while (n&&x/2+10<x) {
			x = x / 2 + 10;
			n--;
		}
		if (x <= m * 10)printf("YES\n");
		else printf("NO\n");
	}
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值