ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

CF1555B Two Tables

2021-10-31 15:34:44  阅读:170  来源: 互联网

标签:CF1555B Tables x1 int Two x2 ans y1 y2


题目链接
在这里插入图片描述

//#include<bits/stdc++.h> 
//using namespace std;
//int main()
//{
//	int t; cin >> t;
//	int n, m;
//	int x1, y1, x2, y2;
//	int w, h;
//	while (t -- )
//	{
//		cin >> n >> m >> x1 >> y1 >> x2 >> y2 >> w >> h;
//		int ans = 999999999;
//		int a = y2 - y1, b = x2 - x1;
//		
//			if (m - y2 >= h || y1 >= h) ans = 0;
//			else
//			{
//				int maxn = max (m - y2, y1);
//				ans = min(ans, h - maxn);
//			}
//			
//			if (n - b >= w && m >= h)
//			{
//				if (n - x2 >= w || x1 >= w) ans = 0;
//				else
//				{
//					int maxn = max (n - x2, x1);
//					ans = min(ans, w - maxn);
//				}
//			}
//			
//			if (ans == 999999999) printf("         -1\n");
//			else printf("                   %d\n", ans);
//		
//	}
//	return 0;
//}
#include<bits/stdc++.h>
using namespace std;

int main()
{
	int a, b, x1, y1, x2, y2, a1, b1, a2, b2;
	int t; cin >> t;
	
	while (t -- )
	{
		cin >> a >> b >> x1 >> y1 >> x2 >> y2 >> a2 >> b2;
		a1 = x2 - x1, b1 = y2 - y1;
		
		if (a1 + a2 > a && b1 + b2 > b) cout << "-1\n";
		else
		{
			int ans = 0x3f3f3f3f;
			if (a1 + a2 <= a)
			{
				if (x1 >= a2 || x2 + a2 <= a) ans = 0;
				else ans = min(ans, min(a2 - x1, x2 + a2 - a));//看哪个要移动的少 
			}
			if (b1 + b2 <= b) 
			{
				if (y1 >= b2 || y2 + b2 <= b) ans = 0;
				else ans = min(ans, min(b2 - y1, y2 + b2 - b));//看哪个要移动的少 
			}
			cout << ans << ".000000000" << endl;
		}
	}
	return 0;
}

标签:CF1555B,Tables,x1,int,Two,x2,ans,y1,y2
来源: https://blog.csdn.net/qq_34682765/article/details/121064587

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有