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 ;
}
A. Vanya and Table的更多相关文章
- Codeforces Round #308 (Div. 2) A. Vanya and Table 暴力
A. Vanya and Table Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/pr ...
- 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table
题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...
- 【84.62%】【codeforces 552A】Vanya and Table
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- #308 (div.2) A. Vanya and Table
1.题目描写叙述:点击打开链接 2.解题思路:本题是一道简单的模拟题.每次扫描一个输入的长方形,然后将内部全部点都+1,终于统计数组全部元素的和就可以. 3.代码: #define _CRT_SECU ...
- Codeforces Round #308 (Div. 2) A B C 水 数学
A. Vanya and Table time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #308 (Div. 2)
A. Vanya and Table Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows ...
- codeforces 677D D. Vanya and Treasure(二维线段树)
题目链接: D. Vanya and Treasure time limit per test 1.5 seconds memory limit per test 256 megabytes inpu ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) C. Table Tennis Game 2 水题
C. Table Tennis Game 2 题目连接: http://codeforces.com/contest/765/problem/C Description Misha and Vanya ...
- Codeforces Round #355 (Div. 2) D. Vanya and Treasure 分治暴力
D. Vanya and Treasure 题目连接: http://www.codeforces.com/contest/677/problem/D Description Vanya is in ...
随机推荐
- 论DATASNAP结合FIREDAC的使用方法
论DATASNAP结合FIREDAC的使用方法 自DELPHI XE5开始引入FIREDAC数据引擎以来,FIREDAC就正式成为了官方的数据引擎.一直到XE10.1 UPDATE1,据笔者观察,FI ...
- 修复OS X的Finder中文档 打开方式中重复程序的问题
如上图,OS X在使用一段时间后,有些软件就会重复注册打开方式,对于有洁癖的人,这是难以接受的事. 不过有个命令可以很简单的把重复项给去掉. /System/Library/Frameworks/Co ...
- JAVA_MyEclipse如何加载Tomcat
注意Tomcat不要放到Program Files这种有空格的路径下面!,下图所示是错误的
- Android中怎样自己制作su
本文原博客:http://hubingforever.blog.163.com/blog/static/171040579201372915716149/ 在Android源代码的system\ext ...
- UFLDL教程笔记及练习答案三(Softmax回归与自我学习***)
:softmax回归 当p(y|x,theta)满足多项式分布,通过GLM对其进行建模就能得到htheta(x)关于theta的函数,将其称为softmax回归. 教程中已经给了cost及gradie ...
- pdf reference 格式具体说明
1. PDF概要 1.1. 图像模型 PDF能以平台无关.高效率的方式描叙复杂的文字.图形.排版. PDF 用图像模型来实现设备无关. 图像模型同意应用程序以抽象对象描叙文字.图像.图标.而不是通过详 ...
- VS2008转VS2013时遇到的问题
最近我们要把DPM进行行人检测嵌入到我们的项目里,需要一个高级版本的VS,于是我们要把2008转换成2013,至于为什么没有换成最高级的版本,可能担心会遇到有更多的麻烦吧,毕竟我们的DPM源码是在20 ...
- COGS28 [NOI2006] 最大获利[最大权闭合子图]
[NOI2006] 最大获利 ★★★☆ 输入文件:profit.in 输出文件:profit.out 简单对比时间限制:2 s 内存限制:512 MB [问题描述] 新的技术正冲击着手 ...
- diamond简介和使用
简介 diamond是淘宝内部使用的一个管理持久配置的系统,它的特点是简单.可靠.易用,目前淘宝内部绝大多数系统的配置,由diamond来进行统一管理. diamond为应用系统提供了获取配置的服务, ...
- mongo-java-driver
http://mvnrepository.com/artifact/org.mongodb/mongo-java-driver/3.5.0 <!-- https://mvnrepository. ...