CodeForces - 552A Vanya and Table (水)
来源:互联网 发布:大数据安全管理 编辑:程序博客网 时间:2024/05/22 05:05
Description
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 100from 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.
Sample Input
21 1 2 32 2 3 3
10
21 1 3 31 1 3 3
18
Hint
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.
Source
#include<stdio.h>#include<string.h>#include<algorithm>#include<iostream>using namespace std;int main(){int n,i,j;int sum;int x1,x2,y1,y2;while(scanf("%d",&n)!=EOF){sum=0;while(n--){scanf("%d%d%d%d",&x1,&y1,&x2,&y2);sum+=(x2-x1+1)*(y2-y1+1);}printf("%d\n",sum);}return 0;}
- CodeForces - 552A Vanya and Table (水)
- CodeForces-552A - Vanya and Table
- CodeForces 552A-Vanya and Table【模拟】
- 【84.62%】【codeforces 552A】Vanya and Table
- A. Vanya and Table(Codeforces Round #308 (Div. 2))
- A. Vanya and Table
- A. Vanya and Table
- coderforce 552A. Vanya and Table
- Codeforces Round #308 (Div. 2) A. Vanya and Table
- Codeforces 492A. Vanya and Cubes 水
- Codeforces 492A Vanya and Cubes(水)
- codeforces A. Vanya and Cards
- CodeForces - 552B Vanya and Books (数学阶乘)水
- #308 (div.2) A. Vanya and Table
- Codeforces 401A Vanya and Cards(水题)
- CodeForces 492A Vanya and Cubes(水题)
- codeforces 677A Vanya and Fence(水题)
- CodeForces 677A Vanya and Fence(轧马路)
- IOS开发中,SVN如何恢复到某一个版本(以Cornerstone为例)
- SVN初识
- uva10564
- 异常捕捉先后顺序------getCustomerInfo()方法如下,try中可以捕获三种类型的异常,如果在该方法运行中产生了一个IOException,将会输出什么结果()
- zufe-机智的zhourist
- CodeForces - 552A Vanya and Table (水)
- APN
- 工作流学习网址
- 使用grunt实现css压缩
- Oracle内置表一
- iOS中解析 XML / JSON格式讲解
- linux管道(pipe)
- iOS 自带定位功能CoreLocation
- log4j config