time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard output

Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows are numbered by integers from 1 to 100 from bottom to top, the columns are numbered from 1 to 100 from left to right.

In this table, Vanya chose n rectangles with sides that go along borders of squares (some rectangles probably occur multiple times). After that for each cell of the table he counted the number of rectangles it belongs to and wrote this number into it. Now he wants to find the sum of values in all cells of the table and as the table is too large, he asks you to help him find the result.

Input

The first line contains integer n (1 ≤ n ≤ 100) — the number of rectangles.

Each of the following n lines contains four integers x1, y1, x2, y2 (1 ≤ x1 ≤ x2 ≤ 100, 1 ≤ y1 ≤ y2 ≤ 100), where x1 and y1 are the number of the column and row of the lower left cell and x2 and y2 are the number of the column and row of the upper right cell of a rectangle.

Output

In a single line print the sum of all values in the cells of the table.

Examples

input

2

1 1 2 3

2 2 3 3

output

10

input

2

1 1 3 3

1 1 3 3

output

18

Note

Note to the first sample test:

Values of the table in the first three rows and columns will be as follows:

121

121

110

So, the sum of values will be equal to 10.

Note to the second sample test:

Values of the table in the first three rows and columns will be as follows:

222

222

222

So, the sum of values will be equal to 18.

【题目链接】:http://codeforces.com/contest/552/problem/A

【题解】



枚举每个矩形占据了哪些格子;

用个数组递增那些位置的值就好了.



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int MAXN = 100+10;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0); int a[MAXN][MAXN];
int n; int main()
{
//freopen("F:\\rush.txt","r",stdin);
rei(n);
rep1(i,1,n)
{
int a1,b1,a2,b2;
scanf("%d%d%d%d",&a1,&b1,&a2,&b2);
rep1(j,b1,b2)
rep1(k,a1,a2)
a[j][k]++;
}
LL ans = 0;
rep1(i,1,100)
rep1(j,1,100)
ans+=a[i][j];
cout << ans << endl;
return 0;
}

最新文章

  1. WindowsFormsHost使用问题
  2. 1.3 Makefile 工程管理
  3. Java.io.DataInputStream.readInt()
  4. CSS 预处理器(框架)初探:Sass、LESS 和 Stylus
  5. ASP.Net软件工程师基础(三)
  6. hdu 4593 Robot
  7. css 常见兼容性问题及解决方案
  8. ASP.net获取当前页面的文件名,参数,域名等方法
  9. SqlBulkCopy类进行大数据(一万条以上)插入测试
  10. asp.net在用户控件中使用ClientScript
  11. HTML5基础篇章1
  12. Tensorflow 基于分层注意网络的文件分类器
  13. [Swift]LeetCode230. 二叉搜索树中第K小的元素 | Kth Smallest Element in a BST
  14. 常用linux命令(项目部署)
  15. Linux 线程】线程同步《四》
  16. centos 7 搭建pip源
  17. python类内部调用自己的成员函数必须加self
  18. Part15 – 前端之jQuery
  19. drupal7 带表达式条件的update
  20. python3登录网页(163邮箱)实例

热门文章

  1. Atcoder At Beginner Contest 068 C - Cat Snuke and a Voyage
  2. qtcreator配置
  3. C语言的多行宏定义
  4. 【AIM Tech Round 4 (Div. 2) B】Rectangles
  5. lighttpd + php for android 安卓上的WEB服务器
  6. Android 开发之锁屏弹窗
  7. 原生js大总结八
  8. C/S与B/S架构比较
  9. Android AutoWrapTextView 解决中英文排版问题
  10. Java核心技术 卷Ⅰ 基础知识(4)