题目链接

题意:

 有一个六边形,给你6条边的长度(顺时针给出)。每条边都是整数,问你它能够被切割成几个单位长度的正三角形 
(题目保证给出的数据能够被切割)
思路:
六边形能够被切割成两种情况:
①被分成上下两个等腰梯形

②被分成等腰梯形-平行四边形-等腰梯形


事实上这两种能够统为一种,由于当另外一种平行四边形的一对平行边长为0的时间就变成了第一种。
给这六条边标号


六边形旋转到某个状态的时候。 一定会形成等腰梯形-平行四边形-等腰梯形的状态(或仅仅有两个等腰梯形)
上下两个梯形的腰各自是 min(a2, a6), min(a3, a5) 平行四边形的一对平行边长为 abs(a2-a6)
将这三块面积加起来就能够了
所以我们仅仅要去寻找a1这条边(for i = 1 ~3),使得 a2 + a6 == a3 + a5 就可以
代码例如以下:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
const int N = 1005;
int n;
int a[10]; int main()
{
for(int i = 1; i <= 6; i++)
{
scanf("%d", &a[i]);
}
for(int i = 1; i <= 3; i++)
{
if((a[2] + a[3]) == (a[5] + a[6])) break;
else
{
int f = a[1];
for(int j = 1; j < 6; j++)
{
a[j] = a[j+1];
}
a[6] = f;
}
}
int x = min(a[2], a[6]), y = min(a[3], a[5]);
int l = abs(a[2] - a[6]);
ll sum = 0;
int cnt = a[1];
for(int i = 1; i <= x; i++)
{
sum += (ll)2 * cnt + 1; //加上上面那个等腰梯形的面积
++cnt;
}
sum += (ll) 2 * cnt * l; //加上平行四边形面积
cnt--;
for(int i = 1; i <= y; i++)
{
sum += (ll)2 * cnt + 1; //加上以下那个等腰梯形的面积
--cnt;
}
printf("%I64d\n", sum);
return 0;
}

Codeforces Round #313 (Div. 2) C的更多相关文章

  1. Codeforces Round #313 (Div. 1)

    官方英文题解:http://codeforces.com/blog/entry/19237 Problem A: 题目大意: 给出内角和均为120°的六边形的六条边长(均为正整数),求最多能划分成多少 ...

  2. dp - Codeforces Round #313 (Div. 1) C. Gerald and Giant Chess

    Gerald and Giant Chess Problem's Link: http://codeforces.com/contest/559/problem/C Mean: 一个n*m的网格,让你 ...

  3. Codeforces Round #313 (Div. 1) B. Equivalent Strings

    Equivalent Strings Problem's Link: http://codeforces.com/contest/559/problem/B Mean: 给定两个等长串s1,s2,判断 ...

  4. Codeforces Round #313 (Div. 1) A. Gerald's Hexagon

    Gerald's Hexagon Problem's Link: http://codeforces.com/contest/559/problem/A Mean: 按顺时针顺序给出一个六边形的各边长 ...

  5. Codeforces Round #313 (Div. 2)B.B. Gerald is into Art

    B. Gerald is into Art Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/ ...

  6. Codeforces Round #313 (Div. 2) D. Equivalent Strings

    D. Equivalent Strings Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/ ...

  7. Codeforces Round #313 (Div. 2) C. Gerald's Hexagon 数学

    C. Gerald's Hexagon Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/pr ...

  8. Codeforces Round #313 (Div. 2) A. Currency System in Geraldion

    A. Currency System in Geraldion Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/co ...

  9. Codeforces Round #313 (Div. 2) E. Gerald and Giant Chess (Lucas + dp)

    题目链接:http://codeforces.com/contest/560/problem/E 给你一个n*m的网格,有k个坏点,问你从(1,1)到(n,m)不经过坏点有多少条路径. 先把这些坏点排 ...

  10. Codeforces Round #313 (Div. 1) B. Equivalent Strings DFS暴力

    B. Equivalent Strings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559 ...

随机推荐

  1. HTML 3秒一换轮播(鼠标选中旋转停止定时) 动画案例

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. mac下selenium+python环境搭建

    selenium2+python的环境搭建主要需要python和selenium 1.python mac下自带了python,可以查看版本.当然可以选择安装其它版本的python. 2.seleni ...

  3. C#实现中国身份证验证问题

    C#中国身份证验证,包括省份验证和校验码验证,符合GB11643-1999标准...   今天写的 C#中国身份证验证,包括省份验证和校验码验证,符合GB11643-1999标准... 理论部分: 1 ...

  4. [转载] 深入了解Java ClassLoader、Bytecode 、ASM、cglib

    转载自http://www.iteye.com/topic/98178   一.Java ClassLoader 1,什么是ClassLoader 与 C 或 C++ 编写的程序不同,Java 程序并 ...

  5. 原生JS—实现图片循环切换及监测鼠标滚动切换图片

    今天我们主要讲讲如何使用原生JS实现图片的循环切换的方法以及如何检测鼠标滚动循环切换图片.多余的话我们就不多说了,我们一个一个开始讲吧. 1  原生JS实现图片循环切换 -- 方法一 在上栗子之前我们 ...

  6. Python的__init__.py用法

    python中包的引入,对于大型项目中都会使用到这个功能,把实现不同功能的python文件放在一起,组成不同lib库,然后在其他地方调用. 包,python源文件+__init__.py 模块,pyt ...

  7. 自己动手修改Robotium代码(上)

    Robotium作为Android自动化测试框架,还有许多不完善的地方,也不能满足测试人员的所有要求.那么,本文以四个实际中碰到的问题为例,介绍改动Robotium源码的过程. public bool ...

  8. org.hibernate.validator.constraints.NotBlank' validating type 'java.lang.Integer

    使用hibernate时,在save方法时,报了:org.hibernate.validator.constraints.NotBlank' validating type 'java.lang.In ...

  9. 分布式缓存之Ehcache与terracotta - Terracotta服务器概念篇

    1.介绍 Terracotta服务器为Terracotta产品提供分布式数据平台.Terracotta服务器集群被称为Terracotta服务器阵列(TSA).Terracotta服务器阵列可以从单个 ...

  10. 加密代理和Retrofit解密Converter

    最近在研究安卓的Retrofit框架,服务器的数据全部用加密算法加密了,发现无法使用"com.squareup.retrofit2:converter-gson:2.1.0"Jar ...