题目链接:点击打开链接

#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. QNetworkRequest 请求类

    QNetworkRequest Class Header:    #include <QNetworkRequest>qmake:     QT += networkSince:     ...

  2. Maya pywin32

    Maya 2011 – 2013 64-bit: maya-64-bit-pywin32.zipMaya 2011 – 2013 32-bit: maya-32-bit-pywin32.zipMaya ...

  3. 写个自动下载安装Ant的shell脚本【二】

    #!/bin/bash ####################################################### file name: install_ant.sh# # fun ...

  4. js 作用域,变量提升

    先看下面一段代码: 代码执行的结果是: 1st alert : a = 0 2nd alert : a = undefined 5th alert : a = 0 3rd alert : a = 3 ...

  5. Astyle:代码格式化工具简明指南

    astyle是一个我自己常用的开放源码工具.它可以方便的将程序代码格式化成自己想要的样式而不必人工修改.本来嘛,作为高等生物应该优先去做一些智慧的事情,而不是把时间消耗在机器可以完美完成的事情上. 想 ...

  6. 研究OpenRisc的高人,几十篇文章

    http://blog.csdn.net/rill_zhen/article/details/8190322 流水线的实现: http://blog.csdn.net/rill_zhen/articl ...

  7. 14.7.2 Changing the Number or Size of InnoDB Redo Log Files 改变InnoDB Redo Log Files的数量和大小

    14.7.2 Changing the Number or Size of InnoDB Redo Log Files 改变InnoDB Redo Log Files的数量和大小 改变 InnoDB ...

  8. REST client 基于浏览器的测试工具

    以前在开发webservice服务,都是自己基于HTTP协议,自己写一个测试程序来进行测试,最近在研究RestFul,对以前webservice服务进行了重构,总结了不少经验,今天就给大家介绍下几款R ...

  9. NOI题库05 派

    05:派 Description 我的生日要到了!根据习俗,我需要将一些派分给大家.我有N个不同口味.不同大小的派.有F个朋友会来参加我的派对,每个人会拿到一块派(必须一个派的一块,不能由几个派的小块 ...

  10. ACM1024动态规划

    #include <cstdio> #include <algorithm> #define FI(a, b, c) for(int a = (b); a <= (c); ...