CodeForces - 1169A A - Circle Metro
程序员文章站
2022-06-27 11:52:22
...
Description:
题意:
两个人坐地铁,一个人从正向走,一个人从反向走,问在到达终点前是否可以在同一时间相遇。地铁是一个环,首尾相连
水题直接模拟就行
AC代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define INF 0x3f3f3f3f
using namespace std;
int main()
{
int n,i,j,k,l,a,b,c,x,y,m;
while(~scanf("%d %d %d %d %d",&n,&a,&x,&b,&y))
{
for(i=0; i<200; i++)
{
if(a==n)
a=1;
else
a++;
if(b==1)
b=n;
else
b--;
if(a==b)
{
c=1;
cout<<"YES";
break;
}
if(a==x)
{
c=0;
break;
}
if(b==y)
{
c=0;
break;
}
}
if(c==0)
cout<<"NO"<<endl;
}
return 0;
}
上一篇: vue push路由报错
推荐阅读
-
A. Circle of Students(遍历匹配)Codeforces Round #579 (Div. 3)
-
CodeForces - 1169A A - Circle Metro
-
Educational Codeforces Round 85 (Rated for Div. 2) C. Circle of Monsters(前缀和 预处理 贪心)
-
codeforces C. Circle of Monsters
-
Codeforces Round #564 (Div. 2) D - Nauuo and Circle(树上排列)
-
Codeforces 1451D. Circle Game(博弈)
-
Codeforces Circle of Monsters(思维)
-
Codeforces Round #685 (Div. 2)——D. Circle Game
-
Codeforces 1451D. Circle Game(博弈)
-
Circle Game CodeForces - 1451D( 博弈 +思维 )