题目链接https://www.luogu.com.cn/problem/U406410
视频讲解
#include<bits/stdc++.h>
using namespace std;
bool m[15];
bool n[15];
int main()
{
int a,b,c,d,e,i;
cin>>a>>b>>c>>d>>e;
if(b!=a-1)
{
cout<<"No";
return 0;
}
else
{
int s1=2*a-1-c;
int s2=2*a-1-d;
int t1=s1-e%s1;
int t2=s2-s2%e;
int bj=1;
for(i=1;i<s1;i++)
{
while(m[bj]!=0)
{
bj++;
if(bj>s1)
bj=1;
}
bj++;
if(bj>s1)
bj=1;
while(m[bj]!=0)
{
bj++;
if(bj>s1)
bj=1;
}
m[bj]=1;
}
if(m[t1]!=0)
{
cout<<"No";
return 0;
}
bj=1;
for(i=1;i<s2;i++)
{
while(n[bj]!=0)
{
bj++;
if(bj>s2)
bj=1;
}
bj++;
if(bj>s2)
bj=1;
while(n[bj]!=0)
{
bj++;
if(bj>s2)
bj=1;
}
n[bj]=1;
}
if(n[t2]!=0)
{
cout<<"No";
return 0;
}
}
cout<<"Yes";
return 0;
}