zoukankan      html  css  js  c++  java
  • cf 15B

    . Laser
    time limit per test
    1 second
    memory limit per test
    64 megabytes
    input
    standard input
    output
    standard output

    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 a1 × 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 nm 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 nmx1, y1, x2, y2, separated by a space (2 ≤ n, m ≤ 109, 1 ≤ x1, x2 ≤ n1 ≤ 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.

    Sample test(s)
    input
    2
    4 4 1 1 3 3
    4 3 1 1 2 2
    output
    8
    2
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<string>
    #include<cmath>
    #include<cstdlib>
    #include<algorithm>
    using namespace std;
    #define LL long long
    LL n,m,a,b,c,d,tt;
    int main()
    {
          scanf("%I64d",&tt);
          while(tt--){
          scanf("%I64d%I64d%I64d%I64d%I64d%I64d",&n,&m,&a,&b,&c,&d);
          LL xx=abs(a-c)+1;
          LL yy=abs(b-d)+1;
          LL ans=(LL)(n-xx+1)*(m-yy+1);
          ans=(LL)ans*2;
          if((n-xx+1)>=xx&&(m-yy+1)>=yy)
                ans-=(n-xx+1-xx+1)*(m-yy+1-yy+1);
          printf("%I64d
    ",n*m-ans);
          }
          return 0;
    }
    

      

  • 相关阅读:
    Java从静态代理到动态代理
    Redis持久化
    Linux top命令详解
    从Java线程到线程池
    NodeJs的学习
    使用<金蝶云星空集成开发平台>创建单据的操作步骤
    Maven项目的创建
    XCX_豆瓣电影
    小程序,新手上路
    更改Apache虚拟目录并授予权限 及 { 修改索引页 }
  • 原文地址:https://www.cnblogs.com/a972290869/p/4224258.html
Copyright © 2011-2022 走看看