Laser
Petya is the most responsible worker in the Research Institute. So he was asked to make a very important experiment: to melt the chocolate bar with a new laser device. The device consists of a rectangular field of n × m cells and a robotic arm. Each cell of the field is a 1 × 1 square. The robotic arm has two lasers pointed at the field perpendicularly to its surface. At any one time lasers are pointed at the centres of some two cells. Since the lasers are on the robotic hand, their movements are synchronized — if you move one of the lasers by a vector, another one moves by the same vector.
The following facts about the experiment are known:
- initially the whole field is covered with a chocolate bar of the size n × m, both lasers are located above the field and are active;
- the chocolate melts within one cell of the field at which the laser is pointed;
- all moves of the robotic arm should be parallel to the sides of the field, after each move the lasers should be pointed at the centres of some two cells;
- at any one time both lasers should be pointed at the field. Petya doesn't want to become a second Gordon Freeman.
You are given n, m and the cells (x1, y1) and (x2, y2), where the lasers are initially pointed at (xi is a column number, yi is a row number). Rows are numbered from 1 to m from top to bottom and columns are numbered from 1 to n from left to right. You are to find the amount of cells of the field on which the chocolate can't be melted in the given conditions.
Input
The first line contains one integer number t (1 ≤ t ≤ 10000) — the number of test sets. Each of the following t lines describes one test set. Each line contains integer numbers n, m, x1, y1, x2, y2, separated by a space (2 ≤ n, m ≤ 109, 1 ≤ x1, x2 ≤ n, 1 ≤ y1, y2 ≤ m). Cells (x1, y1) and (x2, y2) are distinct.
Output
Each of the t lines of the output should contain the answer to the corresponding input test set.
Example
2
4 4 1 1 3 3
4 3 1 1 2 2
8
2 画个图就知道了,一共两种情况,一种是覆盖的两部分各在一角没有重叠,另一种是有重叠,有重叠就用容斥原理。
代码:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath> using namespace std;
int t;
long long m,n,x_1,x_2,y_1,y_2;
int main()
{
scanf("%d",&t);
while(t --)
{
scanf("%lld%lld%lld%lld%lld%lld",&n,&m,&x_1,&y_1,&x_2,&y_2);
long long sx = n - abs(x_1 - x_2),sy = m - abs(y_1 - y_2);
long long tx = abs(x_1 - x_2),ty = abs(y_1 - y_2);
if(tx < sx && ty < sy)cout<<n * m - sx * sy * + (sx - tx) * (sy - ty);
else cout<<n * m - sx * sy * ;
cout<<endl;
}
}
Laser的更多相关文章
- 在ros中使用rplidar Laser发布scan数据--25
原创博客:转载请表明出处:http://www.cnblogs.com/zxouxuewei/ 由于市面上买的激光雷达价格太贵了.所以在学习时会造成很大的经济压力.但是最近好多做机器人核心组件的公司都 ...
- L'opzione di luce del puntatore laser
Prima di tutto, sono di buone dimensioni, non i 'mini' puntatori laser che altri stanno vendendo. È ...
- Il laser che è chiaramente visibile
Prima di quel tempo ho ottenuto questo potente puntatore laser 500mW, non so davvero come questo dis ...
- La nuova tecnologia del puntatore laser
Il potente puntatore laser 20000 mW viene fornito di serie con gestione termica e driver laser di qu ...
- La protezione del puntatore laser
Questo puntatore laser è sempre sufficientemente efficiente per eseguire il test più accurato su qua ...
- Kalman filter, Laser/Lidar measurement
You can download this project from https://github.com/lionzheng10/LaserMeasurement The laser measure ...
- Comparison of Laser SLAM and Visual SLAM
Comparison of Laser SLAM and Visual SLAM 目前,SLAM技术广泛应用于机器人.无人机.无人机.AR.VR等领域,依靠传感器可以实现机器的自主定位.测绘.路径规划 ...
- 【High-Speed and Accurate Laser Scan Matching Using Classified Features】
所谓的"分类特征",就是把特征分成 1. 旋转特征:用直线表示 2. 平移特征,用撕裂点和临界点表示 最大的创新点 应该就是下面的分组吧 匹配的时候,用RANSAC 或者动态规划, ...
- 【A Global Line Matching Algorithm for 2D Laser Scan Matching in Regular Environment】
只看了前面的部分,灭有看实验,觉得整体风格比较傻白甜,与我的想法不谋而合.简单明了,用起来应该比较方便. 初步探测:如果有直线,就给线性插值一下. 分级聚类:利用简单的阈值给聚类了一下,分成了段段. ...
随机推荐
- window + document + height
jQuery(window).height()代表了当前可见区域的大小,而jQuery(document).height()则代表了整个文档的高度,可视具体情况使用. 注意当浏览器窗口大小改变 ...
- Python学习进程(14)异常处理
本节介绍Python进行异常处理的方式,异常处理机制可以帮助我们调试python程序. (1)异常的简介: 异常即是一个事件,该事件会在程序执行过程中发生,影响了程序的正常执行 ...
- 每天一个Linux命令(55)systemctl命令
systemctl命令是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起. (1)用法: 用法: systemctl [参数] [服务 ...
- MySQL修改管理员账户密码
报错提示:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)MySQL代理报错提示: ...
- Linux文件系统管理 fdisk分区命令
概述 我们在安装操作系统的过程中已经对系统硬盘进行了分区,但是如果我新添加了一块硬盘,想要正常使用时,在Linux中有专门的分区命令 fdisk 和 parted.其中 fdisk 命令较为常用,但不 ...
- 【HackerRank】Sherlock and MiniMax
题目连接:Sherlock and MiniMax Watson gives Sherlock an array A1,A2...AN. He asks him to find an integer ...
- Python编程-数据类型方法
一.进制简介 进制也就是进位制,是人们规定的一种进位方法.对于任何一种进制---X进制,就表示某一位置上的数运算时是逢X进一位.十进制是逢十进一,十六进制是逢十六进一,二进制就是逢二进一,以此类推,x ...
- ==、equals与hashCode
== 首先,得说明java数据类型分为基本数据类型和引用数据类型, 基本数据类型有8种: 浮点型:float(4 byte), double(8 byte) 整型:byte(1 byte), sho ...
- 用requests登录微信网页版,并接收发送消息
首先,网页版微信登录大致分为以下几个流程(都是大家可以通过抓包得到): 1.登陆主页后,会生成一个UUID,这是个用户标识,在后面请求二维码会用到 def get_uuid(self): '''获取u ...
- USB引脚及定义
USB 2.0 USB接口定义: USB引脚定义: 针脚 名称 说明 接线颜色 1 VCC +5V电压 红色 2 D- 数据线负极 白色 3 D+ 数据线正极 绿色 4 GND 接地 黑色 Min ...