题意:给定一张表,求从一个起点(x1, y1)出发到(x2, y2)的所有路径的和的不同数量。

分析:数学思维题。

我们先看看每条路径和的关系1--->2--->4--->8--->13,当我们走第二条路径的时候,1--->2--->5--->8--->13的时候,
路径和增加了1,即5比4多了1,我们依次改良,可以发现每次改变路径的时候,总和会增加1,路径的条数为左下(n - 1) * (m - 1)的方格数目再加上起始挑选的路径数目1,所以答案为(x2 - x1) * (y2- y1) + 1。

一般c题是道思维题,如果想不到什么好的方法,我们可以尝试样例,找一个小的数据,再对每一条路径进行计算和,查看条数。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
	int t;
	scanf("%d", &t);

	while (t--)
	{
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

		printf("%lld\n", (long long)(y2 - y1) * (x2 - x1) + 1);
	}
	return 0;
}