程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> Codeforces 112B-Petya and Square(實現)

Codeforces 112B-Petya and Square(實現)

編輯:C++入門知識

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
題意 :有一塊2n*2n的地板,在地板上有一個東西,給出坐標和地板的邊長,現在要將地板切成相等的兩部分,且不能切到那個東西,問能不能切成功。
只要在中間一定不能切。。反之則可
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
const int INF = 0x3f3f3f3f;
#define LL long long
char s[1000000];
int main()
{
	int n,x,y;
	while(~scanf("%d%d%d",&n,&x,&y))
	{
		int tx=n/2,ty=n/2;
		if((x==tx||x==tx+1)&&(y==ty||y==ty+1))
			puts("NO");
		else
			puts("YES");
	}

	return 0;
}


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved