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) is at the intersection of x-th row and y-th column. Upper left cell (1,1) contains an integer 1.
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) in one step you can move to the cell (x+1,y) or (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) to another given cell (x2,y2), if you can only move one cell down or right.

Formally, consider all the paths from the cell (x1,y1) to cell (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 t (1≤t≤57179) — the number of test cases.

Each of the following t lines contains four natural numbers x1, y1, x2, y2 (1≤x1≤x2≤109, 1≤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
4
1 1 2 2
1 2 2 4
179 1 179 100000
5 7 5 7
Output
2
3
1
1
Note
In the first test case there are two possible sums: 1+2+5=8 and 1+3+5=9.
思路:具体的我没有证明,可以看看大佬们怎么证明的。我就是画了几个样例,规律挺明显的。
代码如下:

#include<bits/stdc++.h>
#define ll long long
using namespace std;int a1,b1,a2,b2;
int n,m;int main()
{int t;scanf("%d",&t);while(t--){scanf("%d%d%d%d",&a1,&b1,&a2,&b2);n=a2-a1;m=b2-b1;cout<<(ll)n*(ll)m+1ll<<endl;}return 0;
}

努力加油a啊,(o)/~

Celex Update CodeForces - 1358C(打表找规律)相关推荐

  1. [codeforces 1327E] Count The Blocks 打表找规律+根据规律找公式+优化公式

    Educational Codeforces Round 84 (Rated for Div. 2)   比赛人数13522 [codeforces 1327E]  Count The Blocks  ...

  2. CodeForces - Insertion Sort(打表找规律)

    题目链接:http://codeforces.com/gym/101955/problem/C Time limit:6.0 s Memory limit:1024 MB Problem Descri ...

  3. 点分治问题 ----------- P3727 曼哈顿计划E[点分治+博弈SG函数打表找规律]

    题目链接 解题思路: 1.首先对于每个操作我们实际上是一个博弈问题 对于k=1的操作就是很基础的NIM游戏就是找到一条链的异或和为0 对于k=2的操作通过达打表找规律: 如果s是奇数那么偶数的SG函数 ...

  4. Yet Another Meme Problem(打表找规律)

    Try guessing the statement from this picture http://tiny.cc/ogyoiz. You are given two integers AA an ...

  5. hdu_5894_hannnnah_j’s Biological Test(打表找规律)

    题目链接:hdu_5894_hannnnah_j's Biological Test 题意: 有n个不同的位置围成一个圈,现在要安排m个人坐,每个人至少的间隔为k,问有多少种安排 题解: 先打表找规律 ...

  6. D. Pythagorean Triples(1487D)(打表找规律 + 二分)

    D. Pythagorean Triples(1487D)(打表找规律 + 二分) 题目来源:D. Pythagorean Triples 题意: 给定一个 n,求满足以下条件的数对 (a, b, c ...

  7. Ural 2045. Richness of words 打表找规律

    2045. Richness of words 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=2045 Description For ...

  8. Ural 2037. Richness of binary words 打表找规律 构造

    2037. Richness of binary words 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=2037 Descripti ...

  9. [国家集训队]整数的lqp拆分 数学推导 打表找规律

    题解: 考场上靠打表找规律切的题,不过严谨的数学推导才是本题精妙所在: 求:$\sum\prod_{i=1}^{m}F_{a{i}}$ 设 $f(i)$ 为 $N=i$ 时的答案,$F_{i}$ 为斐 ...

最新文章

  1. Python使用sklearn构建ElasticNet回归模型并指定样本权重:即构建带样本权重(sample_weight)的回归模型
  2. [Linux] 使用noatime属性优化文件系统读取性能
  3. 二 查看oracle归档日志路径
  4. 随笔-使用时间管理有感
  5. android 自定义banner,Android项目 引入Banner开源库(轮播图)
  6. 【4】 Java基础 四
  7. pvrect r语言 聚类_R语言实现KEGG通路富集可视化
  8. NeurIPS 2020 所有RL papers全扫荡
  9. git clone 添加代理_用树莓派3搭建私有git代码仓库
  10. 【jvm】jdk编译-未成功
  11. java.lang.Class.isPrimitive()用法解析
  12. 计算机组成原理——思维导图分享
  13. iOS —— 极光推送和极光IM
  14. 几行代码实现鼠标自动点击电脑屏幕指定位置,防止电脑或远程桌面休眠
  15. mysql查出每个类型时间最早的记录
  16. Ubuntu10.10下安装Tor,PolipoVidalia
  17. EventEmitter练习之--匿名聊天室
  18. c语言第七章函数笔记,我的C语学习笔记-C语言教程(七).doc
  19. 随机森林分析共享单车的需求
  20. hub设备_是快充能手 更是HUB拓展管家 你的移动电源何必仅仅只能充电

热门文章

  1. php 实现百度坐标转换,PHP中腾讯与百度进行坐标转换
  2. 速率法和终点法的区别_生化分析仪检测中的终点法、两点法、双波长法有什么区别...
  3. fun(n) Java_java程序员的kotlin课(N+2):suspending函数执行编排
  4. c语言递归函数变量作用域,C语言课程变量的作用域和生存周期、递归.ppt
  5. mybatis返回null_面试官:你分析过mybatis工作原理吗?
  6. 【BUG记录】在onCreate()方法handler调用方法导致程序闪退
  7. php mvc和mvvm,mvvm模式和mvc模式的区别是什么
  8. 通过ADB命令获取Android手机的分辨率(升级版)
  9. Swift之旅--数据类型
  10. html页面icon字体无法显示,bootstrap中icon字体图标怎么不显示?