专栏文章
题解:P12974 蒸蒸日上
P12974题解参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mip0u1ld
- 此快照首次捕获于
- 2025/12/03 04:19 3 个月前
- 此快照最后确认于
- 2025/12/03 04:19 3 个月前
神秘模拟题。
这道题唯一的难点在于如何计算位置距离。显然位置距离就是两点中间的间隔数。假设两个人位置为 和 ,那么位置距离可以用 这个式子计算。
剩下的考验语言知识,请看代码。
CPP#include<bits/stdc++.h>
using namespace std;
int n;
int a,b,x,y;
string s1,s2;
int dis;
int dis1,dis2;//a算距离,b算距离
signed main(int argc,char *argv[]){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n;//按输入格式输入,注意不要输出多余内容
cin>>a>>x>>s1;
cin>>b>>y>>s2;
//先算出位置距离
dis=min(abs(a-b),n-abs(a-b));
dis1=dis2=dis;
//根据坐骑算出实际距离
if(s1=="+1") dis2++;
if(s1=="-1") dis1--;
if(s2=="+1") dis1++;
if(s2=="-1") dis2--;
//最后判断实际距离与武器攻击距离的关系,输出答案
if(x>=dis1) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
if(y>=dis2) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}
/*
---INFORMATIONS---
TIME:2025-06-28 21:49:15
PROBLEM:P12974
CODE BY __CrossBow_EXE__ Luogu uid967841
*/
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...