Codeforces 15B Laser
题目链接:点击打开链接
#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的更多相关文章
- [Codeforces Round472C] Three-level Laser
[题目链接] https://codeforces.com/contest/957/problem/C [算法] 二分 注意精度问题 时间复杂度 :O(NlogN) [代码] #include< ...
- codeforces 957 C Three-level Laser
题意: 说的是一个电子云的三种状态,但是这不重要. 简单来说,就是在一个升序的序列中找三个数x,y,z,x和z的值之差不超过u,然后使得(z – y) / (z – x)最大. 思路: 使得(z – ...
- codeforces 724
题目链接: http://codeforces.com/contest/724 A. Checking the Calendar time limit per test 1 second memory ...
- [codeforces 241]C. Mirror Box
[codeforces 241]C. Mirror Box 试题描述 Mirror Box is a name of a popular game in the Iranian National Am ...
- Codeforces Gym 100187K K. Perpetuum Mobile 构造
K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/pro ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
随机推荐
- 在本地Apache服务器配置虚拟主机站点
Apache 配置localhost虚拟主机步骤1,打开apache目录下httpd.conf文件,找到如下模块 # Virtual hosts #Include conf ...
- PreResultListener使用
PreResultListener是一个监听器接口,可以在Action处理完之后,系统转入实际视图前被回调. Struts2应用可以给Action.拦截器添加PreResultListener监听器, ...
- 设置服务器远程连接mysql
一直单人开发所以没有考虑过这方面,到新公司要做合作开发,所以要进行设置,然后开始自己搞 下面把过程罗列一下: 1)由于使用的云服务器 ,所以上面都配置好了,直接配置了mysql的命令行输入密码就可以进 ...
- Android开源项目(转载)
第一部分 界面 ImageView.ProgressBar及其他如Dialog.Toast.EditText.TableView.Activity Animation等等. 一.ListView an ...
- Forward reference vs. forward declaration
Q:Im a bit confused. What is the difference between forward declaration and forward reference? Forwa ...
- virtalBox共享文件夹设置
sudo mount -t vboxsf gongxiang /mnt/shared/
- 基于Java的Http服务器几种模式演进
首先抛出问题: 程序1---错误版本 import java.io.IOException; import java.io.InputStream; import java.io.PrintWrite ...
- 滴滴过节送10元打车券是不是bug
自从滴滴跟快的去年合作以后,也不玩烧钱大战了,也没法打到免费的车了,乘客打车优惠也少了. 但是现在的滴滴在过节的时候还是会返滴滴代金券,而且金额都比较大,超出了打车的起步价.半年前这边的司机会经常利用 ...
- BZOJ 1854 游戏
Description lxhgww最近迷上了一款游戏,在游戏里,他拥有很多的装备,每种装备都有\(2\)个属性,这些属性的值用\([1,10000]\)之间的数表示.当他使用某种装备时,他只能使用该 ...
- Choose the best route
hdu 2680:http://acm.hdu.edu.cn/showproblem.php?pid=2680 这道题值得一提的两点:在图论中注意重边问题是必须的,有向无向也是同等重要的,如这道题 f ...