B. Petya and Square
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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 y represents 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.

Output

If the square is possible to cut, print "YES", otherwise print "NO" (without the quotes).

Sample test(s)
Input
4 1 1
Output
YES
Input
2 2 2
Output
NO
Note

A sample test from the statement and one of the possible ways of cutting the square are shown in the picture:

算法分析:从红色区域 往外扩展,红色区域的上下左右,加上左上、右上、左下、右下,总共8块区域(前提是 最多存在8个),这些区域最重要划分到两个大区域中的一个。现在如果红色块在版图的中间线上下,肯定不能划分开的。

#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <iomanip>
#include <algorithm> using namespace std; int main()
{
int n,x,y;
int i, j;
while( cin>>n>>x>>y )
{
int dd=n/2;
if( (x==dd||x==dd+1)&&(y==dd||y==dd+1) )
cout<<"NO\n";
else
cout<<"YES\n";
}
return 0;
}

codeforces 112B Petya and Square的更多相关文章

  1. Codeforces Round #448 C. Square Subsets

    题目链接 Codeforces Round #448 C. Square Subsets 题解 质因数 *质因数 = 平方数,问题转化成求异或方程组解的个数 求出答案就是\(2^{自由元-1}\) , ...

  2. Codeforces 710C. Magic Odd Square n阶幻方

    C. Magic Odd Square time limit per test:1 second memory limit per test:256 megabytes input:standard ...

  3. Codeforces 716C. Plus and Square Root-推公式的数学题

    http://codeforces.com/problemset/problem/716/C codeforces716C. Plus and Square Root 这个题就是推,会推出来规律,发现 ...

  4. CodeForces 362E Petya and Pipes

    Petya and Pipes Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on CodeForces. ...

  5. Codeforces 1187 F - Expected Square Beauty

    F - Expected Square Beauty 思路:https://codeforces.com/blog/entry/68111 代码: #pragma GCC optimize(2) #p ...

  6. Codeforces 715A. Plus and Square Root[数学构造]

    A. Plus and Square Root time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  7. codeforces B. Petya and Staircases 解题报告

    题目链接:http://codeforces.com/problemset/problem/362/B 题目意思:给出整数n和m,表示有n级楼梯和m级dirty的楼梯,接下来m个数表示对应是哪一个数字 ...

  8. 【模拟】Codeforces 710C Magic Odd Square

    题目链接: http://codeforces.com/problemset/problem/710/C 题目大意: 构造一个N*N的幻方.任意可行解. 幻方就是每一行,每一列,两条对角线的和都相等. ...

  9. Codeforces 890C - Petya and Catacombs 模拟

    C. Petya and Catacombstime limit per test1 secondmemory limit per test256 megabytesinputstandard inp ...

随机推荐

  1. ElasticSearch和Hive做整合

    1.上传elasticsearh-hadoop的jar包到server1-hadoop-namenode-01上 在server1-hadoop-namenode-01上执行: cp  /home/d ...

  2. 读取配置文件包含properties和xml文件

    读取properties配置文件 /** * 读取配置文件 * @author ll-t150 */ public class Utils { private static Properties pr ...

  3. 【前端阅读】——《编程之魂》摘记&读后感&思维导图

    前言:这本书全名叫<编程之魂——与27为编程语言创始人对话>,它的内容以采访对话为主,以图通过和顶级大师的真实交流来调查:大师们为什么要创建某种编程语言,它的技术如何开发.如何教授和学习, ...

  4. HTML5 Canvas 绘制佛教万字

    代码如下: <!DOCTYPE html> <html lang="utf-8"> <meta http-equiv="Content-Ty ...

  5. Webpack DLL

    参考自:https://www.jianshu.com/p/a5b3c2284bb6 在用 Webpack 打包的时候,对于一些不经常更新的第三方库,比如 react,lodash,我们希望能和自己的 ...

  6. Interleaving String——是否由两个string交叉、DP

    Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example,Given:s1 = ...

  7. js处理日期格式yyyy-MM-dd hh:mm:ss

    直接上代码: 使用方法: dateformat('h:m:s') => 09:08:11 dateformat('y-M-d h:m:s') => 2018-06-08 09:08:11 ...

  8. javascript if(条件)------------条件中可以使用的值

    1.布尔变量true/false2.数字非0,非NaN/ ( 或NaN) NaN--------Not a Number 3.对象非null/(null或undefined) 4.字符串非空串(&qu ...

  9. How do you stop Ansible from creating .retry files in the home directory?

    There are two options that you can add to the [defaults] section of the ansible.cfg file that will c ...

  10. RF --系统关键字开发

    需求: 接收一个目录路径,自动遍历目录下以及子目录下的所有批处理(.bat) 文件并执行. 首先在..\Python27\Lib\site-packages 目录下创建 CustomLibrary 目 ...