Codeforces 1332 A. Exercising Walk

在这里插入图片描述
在这里插入图片描述

题意:

有一个点在 ( x , y ) (x,y) ,再给一个区域 ( x 1 , y 1 ) (x_1,y_1) ( x 2 , y 2 ) (x_2,y_2) ,。现在给出a、b、c、d,分别表示这个点要向左走 a a 步,向右走 b b 步,向下走 c c 步,向上走 d d 步。现在问你是否可以满足题目的 a b c d abcd 步,且每一步走完后都不超出 ( x 1 , y 1 ) (x_1,y_1) ( x 2 , y 2 ) (x_2,y_2) 的范围。
就是几种情况判断即可,把各种情况考虑全。

AC代码:

int a, b, c, d;
int x, y, x1, yy, x2, y2;
 
int main()
{
	int t;
	sd(t);
	while (t--)
	{
		sdd(a, b);
		sdd(c, d);
		sdd(x, y);
		sdd(x1, yy);
		sdd(x2, y2);
		if (x1 == x2 && (a || b))
			puts("No");
		else if (yy == y2 && (c || d))
			puts("No");
		else if (a < b && (x + b - a) > x2)
			puts("No");
		else if (a > b && (x - (a - b)) < x1)
			puts("No");
		else if (c < d && (y + d - c) > y2)
			puts("No");
		else if (c > d && (y - (c - d)) < yy)
			puts("No");
			else
			puts("Yes");
	}
	return 0;
}
发布了786 篇原创文章 · 获赞 460 · 访问量 24万+

猜你喜欢

转载自blog.csdn.net/qq_43627087/article/details/105239288