【题目链接】: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的更多相关文章

  1. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  2. 【codeforces 128C】Games with Rectangle

    [题目链接]:http://codeforces.com/problemset/problem/128/C [题意] 让你一层一层地在n*m的网格上画k个递进关系的长方形;(要求一个矩形是包含在另外一 ...

  3. 【45.65%】【codeforces 560B】Gerald is into Art

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. 【25.64%】【codeforces 570E】Pig and Palindromes

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  5. 【84.62%】【codeforces 552A】Vanya and Table

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【codeforces 758C】Unfair Poll

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  8. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  9. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

随机推荐

  1. hdu 3836 强连通+缩点:加边构强连通

    #include<stdio.h>//求出其所有的强连通分量缩点,选出出度和入度最大的那个就是要求的边 #include<string.h> #include<stdli ...

  2. hdu 2491 贪心

    #include<stdio.h> #include<stdlib.h> #define N 110000 struct node { int u,v,len,time; }m ...

  3. js 只能输入英文和数字,且首位必须是字母,字母总数不能超过3个,总长度不能超过20!

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  4. Codeforces Round #464 (Div. 2)

    A. Love Triangle time limit per test: 1 second memory limit per test: 256 megabytes input: standard ...

  5. 基本socket api

    socket函数,为了执行网络I/O,一个进程必须做的第一件事就是调用socket函数,并且指定通信协议类型. #include<sys/socket.h> int socket (int ...

  6. 【手势交互】6. 微动VID

    中国 天津 http://www.sharpnow.com/ 微动VID是天津锋时互动科技有限公司开发的中国Leap Motion. 它能够识别并跟踪用户手部的姿态.包含:指尖和掌心的三维空间位置:手 ...

  7. 一个关于Class的小点

    public 是公有 private 是私有 没有写就是private

  8. 【MySQL】MySQL删除匿名用户,保证登录安全

    博客地址已迁往 www.virtclouds.com 原文地址 http://www.virtclouds.com/538.html 很多MySQL程序都会带有匿名登录的功能. 在刚刚安装完MySQL ...

  9. c#自己实现线程池功能(二)

    介绍 在上一篇c#自己实现线程池功能(一)中,我们基本实现了一个能够执行的程序.而不能真正的称作线程池.因为是上篇中的代码有个致命的bug那就是没有任务是并非等待,而是疯狂的进行while循环,并试图 ...

  10. intellij idea 运行jedis

    到这里下载 http://mvnrepository.com/ jar包! 将jar包放入项目目录中,并引入! 引入包到项目中!创建对象! package com.company; import re ...