题目链接:https://codeforces.ml/problemset/problem/1358/C
转自:官方题解 https://codeforces.ml/blog/entry/77869
题意:一个矩形内有多个方格,每个方格都按照顺序填写了一些数。给两个坐标,求这两个坐标间路径经过的数字和不同的条数。
思路:
先找到数字和最小的路径,然后依次改变其和,每次增加1,直到最大。发现路径数就是不属于数字和最小的路径的方格个数+1.
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int main()
{
ios::sync_with_stdio(false);
int T;
cin>>T;
while(T--)
{
long long a,b,c,d;
cin>>a>>b>>c>>d;
cout<<(c-a)*(d-b)+1<<endl;
}
return 0;
}