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;
    }
    

      

  • 相关阅读:
    unity3d 几种镜头畸变
    深度学习主机环境配置: Ubuntu16.04 + GeForce GTX 1070 + CUDA8.0 + cuDNN5.1 + TensorFlow
    Autofac 中间件使用
    NetCore SignalR 重连逻辑实现
    CentOS 7 安装 MySql8.0
    CentOS 7 安装 Nginx
    CentOS 7 安装 Docker
    Nginx 配置站点
    VUE AXIOS 跨域问题
    CentOS 7 安装 MySql 8
  • 原文地址:https://www.cnblogs.com/a972290869/p/4224258.html
Copyright © 2011-2022 走看看