题目链接:点击打开链接

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<set>
#include<vector>
#include<map>
#include<math.h>
#include<queue>
#include<string>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define N 5005
#define ll __int64
inline ll Abs(ll x){return x>0?x:-x;}
int main(){
ll i, j, T;cin>>T;
while(T--){
ll x1,y1,x2,y2,n,m;
scanf("%I64d %I64d %I64d %I64d %I64d %I64d",&n,&m,&x1,&y1,&x2,&y2);
ll minn = min(x1,x2), maxx = max(x1,x2);
x1 = minn, x2 = maxx;
x2 -= x1-1;
x1 = 1;
minn = min(y1,y2), maxx = max(y1,y2);
y1 = minn, y2 = maxx;
y2 -= y1-1;
y1 = 1;
if(x1==x2 || y1==y2) {
if(y1==y2) {
swap(n,m); swap(x1,y1); swap(x2,y2);
}
ll cha1 = y2-y1-1, cha2 = m - y2;
cha1 -= cha2;
cha1 = max(cha1, 0ll);
printf("%I64d\n",n*cha1);
}
else {
ll x3 = x1+(n-x2), y3 = y1+(m-y2);;
if(x3>=(x2-1) && y3>=(y2-1))
printf("%I64d\n", (x2-x1)*(y2-y1)*2);
else
printf("%I64d\n",n*m-(x3-x1+1)*(y3-y1+1)*2);
}
}
return 0;
}

Codeforces 15B Laser的更多相关文章

  1. [Codeforces Round472C] Three-level Laser

    [题目链接] https://codeforces.com/contest/957/problem/C [算法] 二分 注意精度问题 时间复杂度 :O(NlogN) [代码] #include< ...

  2. codeforces 957 C Three-level Laser

    题意: 说的是一个电子云的三种状态,但是这不重要. 简单来说,就是在一个升序的序列中找三个数x,y,z,x和z的值之差不超过u,然后使得(z – y) / (z – x)最大. 思路: 使得(z – ...

  3. codeforces 724

    题目链接: http://codeforces.com/contest/724 A. Checking the Calendar time limit per test 1 second memory ...

  4. [codeforces 241]C. Mirror Box

    [codeforces 241]C. Mirror Box 试题描述 Mirror Box is a name of a popular game in the Iranian National Am ...

  5. Codeforces Gym 100187K K. Perpetuum Mobile 构造

    K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/pro ...

  6. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  7. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  8. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  9. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

随机推荐

  1. WPF学习(二)布局与菜单、工具栏

    布局 //表格①Grid//3列 4行的表格   <Grid>    <Grid.ColumDefinitions>             <ColumnDefinti ...

  2. java 使用substring 截取特殊字符串的后一位或者数字

    关于截取特殊的字符串的后一位或者数字 需求:截取特殊字符为  .   后一位 String[] str = uri.split("/"); String str1 = str[st ...

  3. 控制器view加载

    出自李明杰讲课视频

  4. python消息队列snakemq使用总结

    Python 消息队列snakemq总结 最近学习消息总线zeromq,在网上搜了python实现的消息总线模块,意外发现有个消息队列snakemq,于是拿来研究一下,感觉还是很不错的,入手简单使用也 ...

  5. 学习总结之Log4NET

    通过在网上查找了一些资料,用了些时间学习了log4NET,做了一个小小的总结,说一下它的特点吧 首先呢log4NET是.Net下一个非常优秀的开源日志记录组件.它可以将日志分成不同等级,也可以按照我们 ...

  6. MVC描述对象的类关系图/调用关系图【学习笔记】

  7. 完全卸载mysql 停止服务、卸载相关程序、删除注册表

    本节主要介绍了完全卸载mysql的具体步骤包括停止服务.卸载相关程序.删除注册表等等   1. 停止服务MySQL 2. 卸载mysql相关的程序 3. 删除注册表(运行->regedit),m ...

  8. DPI/PPI/dp/sp/px/pt 移动设计手册

    转自DPI/PPI/dp/sp/px/pt 移动设计手册 做移动设计的同学,不管是原生app或者web app,应该对字体字号都是很头痛的问题.根本原因是,我们用唯一分辨率的电脑,设计各个不同尺寸大小 ...

  9. 【 UVALive - 2197】Paint the Roads(上下界费用流)

    Description In a country there are n cities connected by m one way roads. You can paint any of these ...

  10. 单片机Keil软件仿真与调试技巧

    一.引言 单片机软件开发过程中,软件调试遇到的各种问题常令初学者感到不知所措.实际上.各种仿真开发软件的程序调试基本方法和技巧大同小异,掌握正确的程序调试基本技巧.对于排查这些程序错误问题可以起到举一 ...