3856: Monster

本文解析了3856:Monster题目,介绍了TeacherMai如何通过攻击来减少怪物的生命值,并判断是否能在休息前或经过若干轮攻击后使怪物生命值降至1以下,最终给出解答。

3856: Monster

Time Limit: 1 Sec  Memory Limit: 64 MB
Submit: 351  Solved: 161
[Submit][Status][Discuss]

Description

Teacher Mai has a kingdom. A monster has invaded this kingdom, and Teacher Mai wants to kill it.
 
Monster initially has h HP. And it will die if HP is less than 1.
 
Teacher Mai and monster take turns to do their action. In one round, Teacher Mai can attack the monster so that the HP of the monster will be reduced by a. At the end of this round, the HP of monster will be increased by b.
 
After k consecutive round's attack, Teacher Mai must take a rest in this round. However, he can also choose to take a rest in any round.
 
Output "YES" if Teacher Mai can kill this monster, else output "NO".

 

Input

There are multiple test cases, terminated by a line "0 0 0 0".
 
For each test case, the first line contains four integers h,a,b,k(1<=h,a,b,k <=10^9).

 

Output

For each case, output "Case #k: " first, where k is the case number counting from 1. Then output "YES" if Teacher Mai can kill this monster, else output "NO".

 

Sample Input

5 3 2 2
0 0 0 0

Sample Output

Case #1: NO

HINT

 

Source

By 镇海中学

 

题解:其实,这是一道水题——事实上,的确是道水题——但是,但是——很明显此题很容易WA掉= =

想干掉这个怪,必须要满足三个条件之一——1.可以一击必杀  2.在休息之前可以干掉这个怪 3.每次进行了一个K长度的周期后这个怪的总体血量在下降

(PS:想起来满是童年口袋妖怪的影子啊,但我居然还是WA掉了2次= =)

 1 /**************************************************************
 2     Problem: 3856
 3     User: HansBug
 4     Language: Pascal
 5     Result: Accepted
 6     Time:4 ms
 7     Memory:224 kb
 8 ****************************************************************/
 9  
10 var
11    i,j,k,l,m,n:int64;
12 begin
13      while not(eof) do
14            begin
15                 readln(i,j,k,l);inc(m);
16                 if (i=0) and (j=0) and (k=0) and (l=0) then exit;
17                 write('Case #',m,': ');
18                 if (j>=i) or ((l*j-(l-1)*k)>=i) or ((l*j)>((l+1)*k)) then writeln('YES') else writeln('NO');
19            end;
20 end.

 

 

转载于:https://www.cnblogs.com/HansBug/p/4486524.html

当 OpenCV 无法加载模板图像(`monster_template1.png`、`monster_template2.png`、`monster_template3.png`)并提示检查文件路径和完整性时,可以从以下几个方面解决: #### 检查文件路径 - **确认相对路径或绝对路径**:若使用相对路径,要保证当前工作目录正确。可通过以下代码查看当前工作目录: ```python import os print(os.getcwd()) ``` 若使用绝对路径,要确保路径书写无误。例如在 Windows 系统中,路径分隔符使用双反斜杠 `\\` 或原始字符串 `r'path'`。 - **检查文件是否存在**:使用 `os.path.exists()` 函数检查文件是否存在,示例代码如下: ```python import os template_paths = ['monster_template1.png', 'monster_template2.png', 'monster_template3.png'] for path in template_paths: if os.path.exists(path): print(f"文件 {path} 存在") else: print(f"文件 {path} 不存在") ``` #### 检查文件完整性 - **手动检查文件**:在文件管理器中打开文件,看能否正常打开。若无法打开,可能文件已损坏,需要重新获取该文件。 #### 检查文件编码和格式 - **确认文件格式**:确保文件确实是 `.png` 格式,有时候文件扩展名可能被错误修改。 #### 代码示例 以下是使用 OpenCV 加载图像并检查是否成功加载的代码示例: ```python import cv2 import os template_paths = ['monster_template1.png', 'monster_template2.png', 'monster_template3.png'] for path in template_paths: if os.path.exists(path): image = cv2.imread(path) if image is not None: print(f"成功加载图像 {path}") else: print(f"无法加载图像 {path},可能文件损坏或格式不支持") else: print(f"文件 {path} 不存在") ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值