A. Vanya and Table
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.
InputThe 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.
OutputIn a single line print the sum of all values in the cells of the table.
Examplesinput2
1 1 2 3
2 2 3 3output10input2
1 1 3 3
1 1 3 3output18NoteNote 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.
题意:
给定n组的两点坐标,求以两点做对角顶点的矩形占多少格子即面积和。
附AC代码:
#include<bits/stdc++.h>
using namespace std; int main() {
int n;
cin >> n;
int sum = ;
while (n--) {
int x1, x2, y1,y2;
cin >> x1 >> y1>>x2>>y2;
int x = x2-x1+;
int y = y2-y1+;
sum += x*y;
}
cout << sum << endl;
return ;
}
最新文章
- 在Ubuntu|CentOS上安装Shutter截图工具及快捷键设置
- 第K 小数
- 个人推荐,比较好的MySQL客户端工具
- laravel5.3 笔记一
- 检查ORACLE的警告文件的脚本
- javascrip格式
- css3实现三角形,聊天背景气泡,心形等形状
- iOS中Block介绍(一)基础
- yowsup ( an application to use whatsapp) hack
- 201521123052《Java程序设计》第3周学习总结
- 深入浅出 Spring
- 测试输出System.err与System.out
- soamanager发布的Webservice服务,调用时出现http500报错
- Python OpenCV人脸识别案例
- 【WC2018】州区划分(FWT,动态规划)
- java 线程(四)线程安全 同步方法
- Jquery 插件 图片验证码
- .Net ASP.NET 打开指定文件夹
- scala-02-基本数据类型-string-分支循环
- C#重新启动时,关闭较早的进程
热门文章
- Effective C++ Item 47 请使用 traits classes 表现类型信息
- 内存管理[5]通过 GetProcessHeaps 函数获取了当前进程的堆句柄列表
- PHP中extract()函数的妙用
- MongoDB:分片(简介 &; 自动分片 &; 片键)
- 【转载】C#中回滚TransactionScope的使用方法和原理
- uva 10806 Dijkstra, Dijkstra. (最小费最大流)
- ArcGIS 10.3 for Server新特性介绍
- Android版DesiredCapabilities参数配置
- RabbitMQ/pika模块
- Python 006- python socket编程详细介绍