Codeforces Round #645 (Div. 2) 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.
The first line contains one integer tt (1≤t≤571791≤t≤57179 ) — the number of test cases.
Each of the following tt lines contains four natural numbers x1x1 , y1y1 , x2x2 , y2y2 (1≤x1≤x2≤1091≤x1≤x2≤109 , 1≤y1≤y2≤1091≤y1≤y2≤109 ) — coordinates of the start and the end cells.
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.
4 1 1 2 2 1 2 2 4 179 1 179 100000 5 7 5 7
会发现图中标出的路线每个田字格右上和左下的数字相差1,而这两条路线的数字之和只差1。一直往右再往下是和最小的走法。往右再往下的路径为一条,带有往下再往右拐点
的路径(图中紫色路径)为(x1-x2)*(y1-y2)条,加起来输出即可。
#include <bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--) { int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2; cout<<(long long)(x2-x1)*(y2-y1)+1<<endl; } return 0; }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!