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 ...
随机推荐
- ansible安装及问题解决
本文主要用来安装ansible,在进行安装的时候,也可以使用其他的版本进行安装,本文主要讲述安装ansible的步骤,还有常用问题的解决. 1.查看python版本 由此可以看到python的版本为2 ...
- 【LeetCode】83 - Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...
- 搞JAVA在北京月薪15K的朋友来到厦门却很难找到工作
朋友是搞JAVA开发的,从北京来.来前朋友们都感觉他在厦门应该很快就能找到工作,因为厦门的IT人员很缺. 没想到来厦门大概半个多月了,到现在都还没着落.面试单位每周基本只有两家,而且面试的感觉都说不错 ...
- ps做gif 登陆下拉菜单效果
作者这里仅介绍登录动画的制作思路和简单过程.一些细节的制作,如登录框,每一帧的图像等都需要自己根据参考图慢慢完成.最终效果 1.新建大小适当的文件,背景填充暗蓝色.首先设计一个底座,主要用图层样式来完 ...
- 15+ 易响应的CSS框架快速开启你的敏捷网站项目
由 于移动互联用户的快速增加,现在数量已经超出10亿,几乎可以肯定的是你的网站每天都会有移动用户访问.如果你组织计划创建一个对移动用户友好的浏览体 验,有多个方面需要考虑.响应快速的网站设计似乎现在很 ...
- HDU-3872 Dragon Ball 线段树+DP
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3872 题意:有n个龙珠按顺序放在一列,每个龙珠有一个type和一个权值,要求你把这n个龙珠分成k个段, ...
- 怎么从sqlserver 数据库导出 insert 的数据语句
In SSMS in the Object Explorer, right click on the database right-click and pick "Tasks" a ...
- 验证dictionary重复键
if (dict.ContainsKey("sadsa")) { }
- 企业网管软件实战之SolarWinds LANsurveyor
SolarWinds LANsurveyor是一款比较容易掌握的网络管理软件,他能自动探索你的LAN或WAN,并生成全面的,易于浏览的集成了OSI 2层和 3层 拓扑数据的网络图表.其主要功能有: 1 ...
- MySQL [Warning] Can’t create test file xxx lower-test(转)
add by zhj:修改的数据库的datadir,然后数据库就无法启动了,错误如下 2014-12-11 16:22:57 26309 [Warning] Can't create test fil ...