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;
}

【84.62%】【codeforces 552A】Vanya and Table的更多相关文章

  1. 【 BowWow and the Timetable CodeForces - 1204A 】【思维】

    题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制 ...

  2. 【codeforces 734F】Anton and School

    [题目链接]:http://codeforces.com/problemset/problem/734/F [题意] 给你两个数组b和c; 然后让你找出一个非负数组a满足题中所给关系; [题解] 有个 ...

  3. 【13.77%】【codeforces 734C】Anton and Making Potions

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  5. 【搜索】【并查集】Codeforces 691D Swaps in Permutation

    题目链接: http://codeforces.com/problemset/problem/691/D 题目大意: 给一个1到N的排列,M个操作(1<=N,M<=106),每个操作可以交 ...

  6. 【中途相遇法】【STL】BAPC2014 K Key to Knowledge (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  7. 【链表】【模拟】Codeforces 706E Working routine

    题目链接: http://codeforces.com/problemset/problem/706/E 题目大意: 给一个N*M的矩阵,Q个操作,每次把两个同样大小的子矩阵交换,子矩阵左上角坐标分别 ...

  8. 【数论】【扩展欧几里得】Codeforces 710D Two Arithmetic Progressions

    题目链接: http://codeforces.com/problemset/problem/710/D 题目大意: 两个等差数列a1x+b1和a2x+b2,求L到R区间内重叠的点有几个. 0 < ...

  9. 【动态规划】【最短路】Codeforces 710E Generate a String

    题目链接: http://codeforces.com/problemset/problem/710/E 题目大意: 问写N个字符的最小花费,写一个字符或者删除一个字符花费A,将当前的字符数量翻倍花费 ...

随机推荐

  1. 3/18 Django框架 启动django服务

    web框架:本质是socket服务端,socket通常也被称为"套接字",用于描述IP地址和端口,是一个通信链的句柄,可以用来实现不同虚拟机或不同计算机之间的通信.web框架就是将 ...

  2. CISP/CISA 每日一题 六

    CISA 每日一题(答) 采用电子数据交换 EDI 的好处: 1.较少的书面工作: 2.较少的信息交换错误: 3.改善了数据库到数据库.公司到公司的信息流: 4.没有多余的数据重新键入: 5.较少的通 ...

  3. 【2017"百度之星"程序设计大赛 - 初赛(A)】数据分割

    [链接]http://acm.hdu.edu.cn/showproblem.php?pid=6109 [题意] 在这里写题意 [题解] 要处理的关系越多,肯定就越容易错. ->单调性. 根据这个 ...

  4. OC文件操作、获取文件属性

    #import <Foundation/Foundation.h> //获取文件的属性 int main(int argc, const char * argv[]) { @autorel ...

  5. Appium_Java_API

    1. driver.findElement(MobileBy.AndroidUIAutomator("邀请")).click();2. driver.findElementById ...

  6. Android Set与List之间转化

    List list = new ArrayList(set); Set set = new HashSet(list); //但是有一点,转换当中可能要丢失数据,尤其是从list转换到set的时候,因 ...

  7. 关于python的深浅拷贝、赋值

    https://blog.csdn.net/weixin_39750084/article/details/81435454

  8. Mysql从入门到精通整理

    目录 mysql基础 mysql进阶 mysql高级 mysql优化 正文 数据库是信息化产业的最基础的软件之一,各种管理系统,网站,在线游戏,背后基本都会有数据库的支持. 回到顶部 mysql基础 ...

  9. Docker使用Dockerfile创建Centos(tomcat+jdk)镜像

    原文链接:https://blog.csdn.net/qq_37936542/article/details/80824389 Docker构建镜像的方法主要有两种:    (1)使用docker c ...

  10. 【MemSQL Start[c]UP 3.0 - Round 1 A】 Declined Finalists

    [链接]h在这里写链接 [题意] 在这里写题意 [题解] max(最大值-25,0) [错的次数] 0 [反思] 在这了写反思 [代码] #include <bits/stdc++.h> ...