B. Petya and Square
2 seconds
256 megabytes
standard input
standard output
Little Petya loves playing with squares. Mum bought him a square 2n × 2n in size. Petya marked a cell inside the square and now he is solving the following task.
The task is to draw a broken line that would go along the grid lines and that would cut the square into two equal parts. The cutting line should not have any common points with the marked cell and the resulting two parts should be equal up to rotation.
Petya wants to determine whether it is possible to cut the square in the required manner given the sizes of the square side and the coordinates of the marked cell. Help him.
The first line contains three space-separated integers 2n, x and y (2 ≤ 2n ≤ 100, 1 ≤ x, y ≤ 2n), representing the length of a square's side and the coordinates of the marked cell. It is guaranteed that 2n is even.
The coordinates of the marked cell are represented by a pair of numbers x y, where x represents the number of the row and yrepresents the number of the column. The rows and columns are numbered by consecutive integers from 1 to 2n. The rows are numbered from top to bottom and the columns are numbered from the left to the right.
If the square is possible to cut, print "YES", otherwise print "NO" (without the quotes).
4 1 1
YES
2 2 2
NO
A sample test from the statement and one of the possible ways of cutting the square are shown in the picture:
解题说明:此题是给定一个大正方形中的一个单位块,要求找出一条不与这个单位块有任何公共点的线把该正方形等分为两个形状一样的块。我们都知道如果要二等分一个三角形,无论这条分割线是什么样子的,它肯定会经过正方形的重心,于是这里只要判断这个单位块是不是与重心有公共点即可,也就是判断此块是不是围绕重心的四个小块。
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;int main()
{int n,x,y;scanf("%d %d %d",&n,&x,&y);if((x==n/2||x==n/2+1)&&(y==n/2||y==n/2+1)){printf("NO\n");}else{printf("YES\n");}return 0;
}
B. Petya and Square相关推荐
- 渐进式web应用程序_如何使用渐进式Web应用程序更快,更便宜地构建新应用程序...
渐进式web应用程序 You need an app! The question is- which kind? 您需要一个应用程序! 问题是--哪种? For the last 8 years or ...
- javascript模块_6分钟内您需要了解的有关Javascript模块的所有信息
javascript模块 Note: This post is inspired by and is a summary of this excellent 30-minute video by Ty ...
- Windows上视频的tensorflow对象检测10
Previous article: "TensorFlow Object Detection in Windows (under 30 lines)", covers about ...
- webp图像扩展_WebP图像和性能
webp图像扩展 It's said that a picture is worth a thousand words, but online, a picture can be worth a th ...
- Petya and Countryside
Description Little Petya often travels to his grandmother in the countryside. The grandmother has a ...
- 367. Valid Perfect Square
题目: Given a positive integer num, write a function which returns True if num is a perfect square els ...
- 数据挖掘公司D square nv 完成500万欧元B轮融资
D square nv日前完成 500 万欧元 B 轮融资,融资方为 Gemma Frisius Fonds, Jürgen Ingels, Limburgse Reconversie Maatsch ...
- 经典算法题之Maximal Square
点击上方"小白学视觉",选择加"星标"或"置顶" 重磅干货,第一时间送达 作者:叶 虎 Maximal Square是道非常有意思的算 ...
- Codeforces 895C - Square Subsets
895C - Square Subsets 思路:状压dp. 每个数最大到70,1到70有19个质数,给这19个质数标号,与状态中的每一位对应. 状压:一个数含有这个质因子奇数个,那么他状态的这一位是 ...
最新文章
- python内置函数sorted(x)的作用是_Python内置filter与sorted函数
- UVa1388 - Graveyard
- [问题解决] File /struts-tags not found
- java防止表单二次提交_防止表单重复提交
- Python:利用python语言绘制多个子图经典案例、代码实现之详细攻略
- 位运算和时间复杂度的分析
- Python 绘图问题:Matplotlib中plt.rcParams[]使用方法 rcsetup.py matplotlibrc
- 如何在 .NET Core 中获取 CPU 使用率
- 常哥带你认识NoSQL和Redis的强大
- python爬虫编码转换_Python 爬虫遇到形如 小说 的编码如何转换为中文? - SegmentFault 思否...
- python idle打不开_孩子,给你的Python安个家吧!
- 推荐系统知识梳理——GBDTLR
- winfrom 去掉字符串空格
- 具体数学-第3课(递归式转化为求和求解)
- C语言队列(排队)先进先出.实现全部函数
- R语言apply族函数详解
- 浅析SkipList跳跃表原理及代码实现
- img标签,hr标签
- 中国机器视觉产业全景图谱
- python如何表示小数_小数的定点表示(附python程序)