【题目链接】: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. File System Design Case Studies

    SRC=http://www.cs.rutgers.edu/~pxk/416/notes/13-fs-studies.html Paul Krzyzanowski April 24, 2014 Int ...

  2. 嵌入式linux和pc机的linux对照

    linux本身具备的非常大长处就是稳定,内核精悍,执行时须要的资源少.嵌入式linux和普通linux并无本质差别. 在嵌入式系统上执行linux的一个缺点就是其核心架构没有又一次设计过,而是直接从桌 ...

  3. 在C 函数中保存状态:registry、reference和upvalues

    在C函数中保存状态:registry.reference和upvalues      C函数能够通过堆栈来和Lua交换数据,但有时候C函数须要在函数体的作用域之外保存某些Lua数据.那么我们想到全局变 ...

  4. ORACLE 參数文件介绍

    ORACLE数据库启动以后.通过select * from v$parameter这个语句能够查看到oracle数据库使用的全部參数. 对于oracle的參数文件,分为spfile 二进制文件和pfi ...

  5. UVA - 10043 Chainsaw Massacre

    Description  Problem E: Chainsaw Massacre  Background As every year the Canadian Lumberjack Society ...

  6. 非Qt工程使用Qt的信号槽机制

    非Qt工程,使用Qt的信号槽机制,蛋疼不?反正我现在就是要做这样一件蛋疼的事. 要使用Qt的信号槽机制,下面是从Qt Assist里面关于 signal & slots 的一句介绍: All ...

  7. c7---函数

    // // main.c // 函数练习 // // Created by xiaomage on 15/6/7. // Copyright (c) 2015年 xiaomage. All right ...

  8. php静态函数的使用场景

    php静态函数的使用场景 场景 代码 <?php class Conductor{ public static $i = 100; public function sold(){ $a = se ...

  9. hdoj--2579--Dating with girls(2)(搜索+三维标记)

    Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  10. 基于macOS+VMware的GNS3内VM上公网

    笔者经常需要做网络实验,GNS3就是笔者最喜欢用的模拟器,为了便于实验,需要能从macos上直接ssh登陆模拟出来的vm,并且vm需要上公网.经过研究,已解决此问题,并以此分享出来 tag: maco ...