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】
只看了前面的部分,灭有看实验,觉得整体风格比较傻白甜,与我的想法不谋而合.简单明了,用起来应该比较方便. 初步探测:如果有直线,就给线性插值一下. 分级聚类:利用简单的阈值给聚类了一下,分成了段段. ...
随机推荐
- Informatica can bind a LONG value only for insert into a LONG column Oracle
Informatica实现etl同步表数据信息时 报: Severity Timestamp Node Thread Message Code Message ERROR 2016/8/8 17:32 ...
- selection createTextRange setSelectionRange
http://www.cnblogs.com/rainman/archive/2011/02/27/1966482.html http://www.zhangxinxu.com/wordpress/2 ...
- 计算机网络概述---传输层 UDP和TCP
传输层的功能 传输层为应用进程间提供端到端的逻辑通信(网络层是提供主机之间的逻辑通信), 传输层两大重要的功能:复用 和 分用. 复用:在发送端,多个应用进程公用一个传输层: 分用:在接收端,传输层会 ...
- VMware VIC
vSphere Integrated Containers - a short intro High-Level view of VCH Networking vSphere Integrated C ...
- Oracle常用知识小总结
永不放弃,一切皆有可能!!! 只为成功找方法,不为失败找借口! Oracle常用知识小总结 1. 创建自增主键 对于习惯了SQL SERVER的图形化界面操作的SQLer,很长一段时间不用oracle ...
- 使用easyui的form提交表单,在IE下出现类似附件下载时提示是否保存的现象
之前开发时遇到的一个问题,使用easyui的form提交表单,在Chrome下时没问题的,但是在IE下出现类似附件下载时提示是否保存的现象. 这里记录一下如何解决的.其实这个现象不光是easyui的f ...
- 为什么原生的servlet是线程不安全的而Struts2是线程安全的?
因为原生的servlet在整个application生命周期中,只在初次访问的时候实例化一次,以后都不会再实例化,只会调用Server方法进行响应,所以如果在servlet类中定义成员变量,那么就会让 ...
- Avoid RegionServer Hotspotting Despite Sequential Keys
n HBase world, RegionServer hotspotting is a common problem. We can describe this problem with a si ...
- tp5定时器
# 定时器 * * * * * cd /home/wwwroot/default/dexin/dragon && /usr/bin/php think order --option 1 ...
- CEF3.2623使用记录:windows编译
CEF3.2623使用记录:windows编译 1:cef3.2623下载地址 2623是cef3最后一个支持xp系统的版本,且可以支持html的audio标签,可以用作对html音频的处理下载地址为 ...