题解:洛谷 AT_abc461_a [ABC461A] Armor
本文分享的必刷题目是从蓝桥云课、洛谷、AcWing等知名刷题平台精心挑选而来,并结合各平台提供的算法标签和难度等级进行了系统分类。题目涵盖了从基础到进阶的多种算法和数据结构,旨在为不同阶段的编程学习者提供一条清晰、平稳的学习提升路径。
欢迎大家订阅我的专栏:算法题解:C++与Python实现!
附上汇总贴:算法竞赛备考冲刺必刷题(C++) | 汇总
【题目来源】
洛谷:AT_abc461_a [ABC461A] Armor - 洛谷
【题目描述】
Takahashi is wearing armor.
This armor blocks all attacks with power (strength represented as an integer) ofD DDor less, but does not block attacks with power greater thanD DD.
Does this armor block an attack with powerA AA?
高桥穿着盔甲。
这副盔甲能抵挡所有威力(用整数表示)为D DD或更低的攻击,但不能抵挡威力大于D DD的攻击。
这副盔甲是否能抵挡威力为A AA的攻击?
【输入】
The input is given from Standard Input in the following format:
A AAD DD
【输出】
OutputYesif the armor blocks the attack, andNootherwise.
【输入样例】
4 5【输出样例】
Yes【算法标签】
#模拟
【代码详解】
#include<bits/stdc++.h>usingnamespacestd;inta,d;// 距离a,跳跃能力dintmain()// 主函数{cin>>a>>d;// 输入距离a和跳跃能力dif(d>=a)// 如果跳跃能力大于等于距离cout<<"Yes"<<endl;// 可以一次跳过else// 否则cout<<"No"<<endl;// 不能一次跳过return0;// 程序正常结束}【运行结果】
4 5 Yes