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/problem/A
Description
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
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
2
1 1 2 3
2 2 3 3
Sample Output
10
HINT
题意
有n个操作,每次操作会将使得一个矩形区域都加上1
然后问你这个100×100的区域的和是多少
题解:
数据范围很小,暴力做就好了
代码:
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 1000010
#define mod 1000000007
#define eps 1e-6
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** ll g[][]; int main()
{
int n=read();
for(int ii=;ii<n;ii++)
{
int x1=read(),y1=read(),x2=read(),y2=read();
for(int i=x1;i<=x2;i++)
{
for(int j=y1;j<=y2;j++)
g[i][j]++;
}
}
ll ans=;
for(int i=;i<=;i++)
{
for(int j=;j<=;j++)
ans+=g[i][j];
}
cout<<ans<<endl;
}
Codeforces Round #308 (Div. 2) A. Vanya and Table 暴力的更多相关文章
- 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table
题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...
- 数学 Codeforces Round #308 (Div. 2) B. Vanya and Books
题目传送门 /* 水题:求总数字个数,开long long竟然莫名其妙WA了几次,也没改啥又对了:) */ #include <cstdio> #include <iostream& ...
- 暴力/进制转换 Codeforces Round #308 (Div. 2) C. Vanya and Scales
题目传送门 /* 题意:问是否能用质量为w^0,w^1,...,w^100的砝码各1个称出重量m,砝码放左边或在右边 暴力/进制转换:假设可以称出,用w进制表示,每一位是0,1,w-1.w-1表示砝码 ...
- Codeforces Round #308 (Div. 2) D. Vanya and Triangles 水题
D. Vanya and Triangles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55 ...
- Codeforces Round #308 (Div. 2) C. Vanya and Scales dfs
C. Vanya and Scales Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/p ...
- Codeforces Round #308 (Div. 2)B. Vanya and Books 数学
B. Vanya and Books Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/pr ...
- Codeforces Round #308 (Div. 2)----C. Vanya and Scales
C. Vanya and Scales time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #297 (Div. 2)D. Arthur and Walls 暴力搜索
Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec Memory Limit: 512 MBSubmit: xxx ...
- Codeforces Round #308 (Div. 2)
A. Vanya and Table Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows ...
随机推荐
- delphi 怎么把image上的图片粘贴到剪切板上
这个给你一个简单的代码,仅提供思路. uses Clipbrd; //引用单元 procedure TForm1.Button1Click(Sender: TObject); var Bmp: TBi ...
- cdh5.4、cm5.4 安装详细步骤
安装准备: 1.centos6.5 64位 虚拟机,内存分配4G.硬盘位20G 2.cm5.4 cdh5.4 包 安装步骤 一.centos安装完后,进行系统配置 1.关闭防火墙 service ip ...
- static public和 public static 区别
static:加static 的是静态成员,不能实例化在你运行的时候他自己在内存中开辟了块空间,不用在new, 有点像全局变量,如果不用你必须去 实例化(new)才能用 static是静态的意思,pu ...
- Hadoop第三天---分布式文件系统HDFS(大数据存储实战)
1.开机启动Hadoop,输入命令: 检查相关进程的启动情况: 2.对Hadoop集群做一个测试: 可以看到新建的test1.txt和test2.txt已经成功地拷贝到节点上(伪分布式只有一个节 ...
- Hadoop学习笔记3---安装并运行Hadoop
本文环境是在Ubuntu10.04环境下运行的. 在Linux上安装Hadoop之前,首先安装两个程序: 1.JDK1.6(或更高版本).Hadoop是用Java编写的程序,Hadoop编译及MapR ...
- jszs 对象引用
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- android 运行 python
Jython is an implementation of the Python programming language designed to run on the Java platform. ...
- centos下apache安装后无法访问
2013.11.28遇到的问题: -------------------------------------- 一.centos下apache安装后无法访问 得查一下防火墙的问题 iptables添加 ...
- UVa11997K Smallest Sums(优先队列)
K Smallest Sums You're given k arrays, each array has k integers. There are kk ways to pick exactly ...
- HDU 4599 Dice (概率DP+数学+快速幂)
题意:给定三个表达式,问你求出最小的m1,m2,满足G(m1) >= F(n), G(m2) >= G(n). 析:这个题是一个概率DP,但是并没有那么简单,运算过程很麻烦. 先分析F(n ...