zoukankan      html  css  js  c++  java
  • C. Celex Update

    During the quarantine, Sicromoft has more free time to create the new functions in "Celex-2021". The developers made a new function GAZ-GIZ, which infinitely fills an infinite table to the right and down from the upper left corner as follows:

    The cell with coordinates (x,y)(x,y) is at the intersection of xx-th row and yy-th column. Upper left cell (1,1)(1,1) contains an integer 11.

    The developers of the SUM function don't sleep either. Because of the boredom, they teamed up with the developers of the RAND function, so they added the ability to calculate the sum on an arbitrary path from one cell to another, moving down or right. Formally, from the cell (x,y)(x,y) in one step you can move to the cell (x+1,y)(x+1,y) or (x,y+1)(x,y+1).

    After another Dinwows update, Levian started to study "Celex-2021" (because he wants to be an accountant!). After filling in the table with the GAZ-GIZ function, he asked you to calculate the quantity of possible different amounts on the path from a given cell (x1,y1)(x1,y1) to another given cell (x2,y2(x2,y2), if you can only move one cell down or right.

    Formally, consider all the paths from the cell (x1,y1)(x1,y1) to cell (x2,y2)(x2,y2) such that each next cell in the path is located either to the down or to the right of the previous one. Calculate the number of different sums of elements for all such paths.

    Input

    The first line contains one integer tt (1t571791≤t≤57179) — the number of test cases.

    Each of the following tt lines contains four natural numbers x1x1, y1y1, x2x2, y2y2 (1x1x21091≤x1≤x2≤109, 1y1y21091≤y1≤y2≤109) — coordinates of the start and the end cells.

    Output

    For each test case, in a separate line, print the number of possible different sums on the way from the start cell to the end cell.

    Example
    input
    Copy
    4
    1 1 2 2
    1 2 2 4
    179 1 179 100000
    5 7 5 7
    
    output
    Copy
    2
    3
    1
    1
    
    Note

    In the first test case there are two possible sums: 1+2+5=81+2+5=8 and 1+3+5=91+3+5=9.

    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <string>
    #include <set>
    #include <queue>
    #include <map>
    #include <sstream>
    #include <cstdio>
    #include <cstring>
    #include <numeric>
    #include <cmath>
    #include <iomanip>
    #include <deque>
    #include <bitset>
    #define ll              long long
    #define PII             pair<int, int>
    #define rep(i,a,b)      for(int  i=a;i<=b;i++)
    #define dec(i,a,b)      for(int  i=a;i>=b;i--)
    #define pb              push_back
    #define mk              make_pair
    using namespace std;
    int dir[4][2] = { { 0,1 } ,{ 0,-1 },{ 1,0 },{ -1,0 } };
    const long long INF = 0x7f7f7f7f7f7f7f7f;
    const int inf = 0x3f3f3f3f;
    const double pi = 3.14159265358979323846;
    const int mod = 998244353;
    const int N = 2e5 + 5;
    //if(x<0 || x>=r || y<0 || y>=c)
    
    inline ll read()
    {
        ll x = 0; bool f = true; char c = getchar();
        while (c < '0' || c > '9') { if (c == '-') f = false; c = getchar(); }
        while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
        return f ? x : -x;
    }
    
    ll gcd(ll m, ll n)
    {
        return n == 0 ? m : gcd(n, m % n);
    }
    ll lcm(ll m, ll n)
    {
        return m * n / gcd(m, n);
    }
    
    int main()
    {
        int T;
        cin >> T;
        while (T--)
        {
            ll x1, x2, y1, y2;
            cin >> x1 >> y1 >> x2 >> y2;
    
            cout << (x2-x1)*(y2-y1)+1<< endl;;
        }
        return 0;
    }
  • 相关阅读:
    问题:弹窗还没点击确认就执行了跳转
    关于版本的问题
    timeUtil
    使用jframe编写一个base64加密解密工具
    JMeter 命令行(非GUI模式)详解(一)-分布式(远程)执行脚本及查看指定结果、日志
    jmeter分布式压测 java.io.FileNotFoundException: rmi_keystore.jks (系统找不到指定的文件。)
    mysql5.7日志时间与系统时间不一致
    mysql查看执行sql语句的记录日志
    Appium如何获取appPackage和appActivity
    关于测试设置
  • 原文地址:https://www.cnblogs.com/dealer/p/12970208.html
Copyright © 2011-2022 走看看