CF1463-A. Dungeon
题意:
你面前有三个怪物,他们分别有a, b, c点血量。现在你可以指定一个怪物,用大炮向他们射击,之后该怪物就会掉一滴血。每七次射击就会使得炮弹威力加强一次,即第7, 14, 21次射击的时候炮弹威力会被加强,加强的炮弹可以对三个怪物分别造成一点伤害。现在问你可不可能在某次被加强的炮弹发射后,使得所有的怪物血量变成0。
思路:
首先每七次射击,总共会造成9点伤害(6 + 3),因此如果要让所有怪物在某次被加强的炮弹发射后血量变为0,则需要他们的血量和为9的倍数。其次每个怪物的血量不能少于被加强的炮弹的发射个数,因为每次被加强的炮弹发射后所有的怪物血量都会减一,而血量不会不会为负数。
AC代码:
#include <cstdio>
#include <algorithm>
const int inf = 0x3f3f3f3f;
int main () {
int T, a[3];
scanf ("%d", &T);
while (T--) {
int tot = 0, minn = inf;
for (int i = 0; i < 3; i++) {
scanf ("%d", &a[i]);
tot += a[i];
minn = std::min (minn, a[i]);
}
if (minn < tot / 9 || tot % 9 != 0) {
printf ("NO\n");
} else {
printf ("YES\n");
}
}
return 0;
}
CF1463-A. Dungeon的更多相关文章
- [LeetCode] Dungeon Game 地牢游戏
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...
- POJ 2251 Dungeon Master(3D迷宫 bfs)
传送门 Dungeon Master Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 28416 Accepted: 11 ...
- poj 2251 Dungeon Master
http://poj.org/problem?id=2251 Dungeon Master Time Limit: 1000MS Memory Limit: 65536K Total Submis ...
- ✡ leetcode 174. Dungeon Game 地牢游戏 --------- java
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...
- leetcode174. Dungeon Game
// learn from https://discuss.leetcode.com/topic/6912/c-dp-solution ''' class Solution { public: int ...
- 【leetcode】Dungeon Game
Dungeon Game The demons had captured the princess (P) and imprisoned her in the bottom-right corner ...
- Dungeon Game ——动态规划
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...
- Java for LeetCode 174 Dungeon Game
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...
- LeetCode Dungeon Game
原题链接在这里:https://leetcode.com/problems/dungeon-game/ 这是一道DP题,保存当前格到右下格所需要的最小体力,m*n的dp数组保存. 更新是Math.mi ...
- Dungeon Master 分类: 搜索 POJ 2015-08-09 14:25 4人阅读 评论(0) 收藏
Dungeon Master Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20995 Accepted: 8150 Descr ...
随机推荐
- 彻底搞懂MySQL为什么要使用B+树索引
目录 MySQL的存储结构 表存储结构 B+树索引结构 B+树页节点结构 为什么要用B+树索引 二叉树 多叉树 B树 B+树 搞懂这个问题之前,我们首先来看一下,MySQL表的存储结构 MySQL的存 ...
- JVM 判断对象已死,实践验证GC回收
作者:小傅哥 博客:https://bugstack.cn 沉淀.分享.成长,让自己和他人都能有所收获! 一.前言 提升自身价值有多重要? 经过了风风雨雨,看过了男男女女.时间经过的岁月就没有永恒不变 ...
- 宝塔的url计划任务
to通过url访问 就像访问你的网站一样 然后控制器/方法里面写你要做的操作 就可以了 ,简单的一批
- openshift 3.11安装部署
openshift 3.11 安装部署 openshift安装部署 1 环境准备(所有节点) openshift 版本 v3.11 1.1 机器环境 ip cpu mem hostname OSsys ...
- Eureka详解系列(一)--先谈谈负载均衡器
这个系列开始研究 Eureka,在此之前,先来谈谈负载均衡器. 本质上,Eureka 就是一个负载均衡器,可能有的人会说,它是一个服务注册中心,用来注册服务的,这种说法不能说错,只是有点片面. 在这篇 ...
- mysql半同步复制跟无损半同步区别
mysql半同步复制跟无损半同步复制的区别: 无损复制其实就是对semi sync增加了rpl_semi_sync_master_wait_point参数,来控制半同步模式下主库在返回给会话事务成功之 ...
- jQuery 自动生成二维码
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta http ...
- Before you launch a goroutine, know when it will stop The Zen of Go
The Zen of Go https://the-zen-of-go.netlify.app/ Ten engineering values for writing simple, readable ...
- mail Header Injection Exploit
Preventing Email Header Injection - PHundamental PHP Best Practices - http://nyphp.org/phundamentals ...
- 策略模式 VS 状态模式
策略模式 VS 状态模式 策略模式 VS 状态模式 | 菜鸟教程 https://www.runoob.com/w3cnote/state-vs-strategy.html