【codeforces 630E】A rectangle
【题目链接】:http://codeforces.com/problemset/problem/630/E
【题意】
给你一个矩形的区域;
然后让你统计这个矩形区域内,有多少个正六边形.
【题解】
规律题;
x轴的话,每个整数都对应了一个正六边形;
然后y轴的话;大概能看出来,每间隔两个整数对应一个正六边形;
然后如果y的差为偶数的话;
有一半会少一个;
需要减掉;
奇数就不用减;
【Number Of WA】
0
【完整代码】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0),cin.tie(0)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110;
LL x1,y1,x2,y2,ans;
int main(){
//Open();
Close();//scanf,puts,printf not use
//init??????
cin >> x1 >> y1 >> x2 >> y2;
LL temp = y2-y1;
if (temp%2==0){
ans = (x2-x1+1)*((y2-y1+2)/2)-(x2-x1+1)/2;
}
else{
ans = (x2-x1+1)*((y2-y1+2)/2);
}
cout << ans << endl;
return 0;
}
【codeforces 630E】A rectangle的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【codeforces 128C】Games with Rectangle
[题目链接]:http://codeforces.com/problemset/problem/128/C [题意] 让你一层一层地在n*m的网格上画k个递进关系的长方形;(要求一个矩形是包含在另外一 ...
- 【45.65%】【codeforces 560B】Gerald is into Art
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【25.64%】【codeforces 570E】Pig and Palindromes
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【84.62%】【codeforces 552A】Vanya and Table
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 758C】Unfair Poll
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
随机推荐
- 【hihocoder 1303】模线性方程组
[题目链接]:http://hihocoder.com/problemset/problem/1303 [题意] [题解] /* x % m[1] = r[1] x % m[2] = r[2] x = ...
- SSM整合(spring,spirngmvc,mybatis)
整合思路 准备环境:导入jar包(spring mybatis dbcp连接池 mysql驱动包 log4j) 工程结构: --------------------------- 1. 整合 ...
- Ubuntu14.04 安装CUDA7.5 + Caffe + cuDNN
本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50961542 花了一天时间,在电脑上安 ...
- python 在爬虫中timeout设置超时有什么作用
是为了防止url不可访问,或者响应速度太慢而造成的时间浪费. 比如,你要爬取1000个网站,如果有100个需要30s才能返回数据,你等待他们返回的话就需要3000s了,如果你设置10s超时,那么就能知 ...
- etymology-R
1)vor = to eat devour vt. 狼吞虎咽地吃光: 吞没,毁灭: 目不转睛地看[de-向下+vour-吃] voracity n.贪食,贪婪.拉丁词根vor-,vorac-表示吞食 ...
- man pthread_mutex_init 或 man pthread_mutex_lock 没有结果的解决的方法
问题: 在刚装好的 Mint/Ubuntu 可能会出现 man pthread_mutex 相关的函数没结果, 报No manual entry for pthread_mutex_init 的错误. ...
- 使用GitHub来托管Larval框架
每个新框架都有自己的安装方法laravel 的安装方法有一下几种: (一) 通过下载 Laravel 包安装 (1) 安装Composer (2) 下载最新Larvel框架 https://g ...
- unity坐标转换问题
unity最经常使用的几种坐标.屏幕坐标.世界坐标.ngui坐标,相对于父物体的坐标(localPoisition). 可是有时候这几种坐标相互转换何其困难,让自己狠抓头. 不得不操作的方式是创建虚拟 ...
- Educational Codeforces Round 12 E. Beautiful Subarrays trie求两异或值大于等于k对数
E. Beautiful Subarrays One day, ZS the Coder wrote down an array of integers a with elements a1, ...
- luogu 1593 因子和
因子和 题目描述 输入两个正整数a和b,求\(a^b\)的因子和.结果太大,只要输出它对9901的余数. 解法 基本算数定理,每一个数都可以被分解成一系列的素数的乘积,然后你可以分解出因数了. 如何求 ...