codeforces 112B Petya and Square

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;
}

 

转载于:https://www.cnblogs.com/yspworld/p/4029585.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值