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 ...
随机推荐
- selenium python (一) 开发环境搭建
1.工具下载: python工具共包括三个:python.setuptools.pip ² python:http://python.org/getit/ python开发环境: ² se ...
- IOS播放音乐和音效
1.播放音效 1.1 首先获取到音效文件路径 NSString *path = [[NSBundle mainBundle] pathForResource:soundFileName ofType: ...
- char型指针与其它指针或数组的细节
一道常见题 char * str7="abc"; char * str8="abc"; cout<<(str7==str8)<<endl ...
- strcpy()的实现
看到有一个博客讲的比平时理解的更深入,mark一下:strcpy函数的实现 这里只写平时理解的,三个要点: //strcpy自己实现 char *strcpy(char *dest, const ch ...
- 面经-csdn
刚刚看的博文:http://blog.csdn.net/ns_code/article/details/40408397 里面有些资料值得学习! 写在前面 结束了在百度的实习,是时候写下校招的总结了, ...
- SpringMVC + Spring + MyBatis 学习笔记:为MyBatis增加打印SQL功能 (最简化配置)
系统:WIN8.1 数据库:Oracle 11GR2 开发工具:MyEclipse 8.6 框架:Spring3.2.9.SpringMVC3.2.9.MyBatis3.2.8 1.以下jar包拷贝到 ...
- I-frame、B-frame、P-frame及DTS、PTS的关系(转)
基本概念: I frame :帧内编码帧 又称intra picture,I 帧通常是每个 GOP(MPEG 所使用的一种视频压缩技术)的第一个帧,经过适度地压缩,做为随机访问的参考点,可以当成图象. ...
- GitHub--git push出错解决
当使用GitHub进行代码push是,出现了下面的错误,该如何是好? 错误描述: ! [rejected] master -> master (non-fast-forward)e ...
- Ruiy自我识人做事领悟录ing
是坑总需要人去踩,谁踩谁收获! 做人做事分层分次,后方能至始及终不乱; 做人做事切记诚记信,宁他人负我,我定不负他人! 做人做事做力求清心寡欲; 安静做工,沉静学道;
- ntpdate server时出错原因及解决
错误1.Server dropped: Strata too high 在ntp客户端运行ntpdate serverIP,出现no server suitable for synchronizati ...