【牛客 - 302哈尔滨理工大学软件与微电子学院第八届程序设计竞赛同步赛(低年级)】小乐乐切割方块(思维,水题)

版权声明:欢迎学习我的博客,希望ACM的发展越来越好~ https://blog.csdn.net/qq_41289920/article/details/84728742

题干:
 

小乐乐的作业本是2n*2n的方格本。

某天小乐乐的童鞋,想要考验一下小乐乐。

他将小乐乐的一张方格纸中的某个格子(x,y)涂成黑色,

小乐乐能否在将4*4的方格本沿着方格边缘且切割线与黑色方格不存在公共交点的情况下将方格本切割成两部分。

两部分可以通过旋转重合。

输入描述:

输入整数2n,x,y。(2 ≤ 2n≤ 100, 1 ≤x,y≤ 2n)

输出描述:

如果能完成切割输出"Yes",否则输出"No"。

示例1

输入

复制

4 1 1

输出

复制

Yes

说明

 

图片提供两种切割方式(切割方式不仅限这两种)。

解题报告:

  思维一下,,,不难证明,,只要不放在中间方块就可以。。其实就是个先猜结论再证明的方法。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 2e5 + 5;
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    if((x>=n/2&&x<=n/2+1)&&(y>=n/2&&y<=n/2+1)) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_41289920/article/details/84728742