题目链接

题意:

 有一个六边形,给你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. Java面试题解构

    有次一个同事让我一同去面试一个候选人,没仔细看简历,所以在问了设计模式之后就让他谈一谈对内存泄漏和垃圾回收的理解,当时候选人一下子就懵了.后来才知道,他面的是初.中级开发职位,想来估计候选人心里也在骂 ...

  2. An explicit value for the identity column in table can only be specified when a column list is used and IDENTITY_INSERT is ON

    If you run into the following error message: An explicit value for the identity column in table '< ...

  3. SQLServer2008数据库安装图解

    SQLServer2008数据库安装图解... ======================================= 解压下载的安装包,右键运行Setup.exe文件 =========== ...

  4. Scrum Meeting Alpha - 9

    Scrum Meeting Alpha - 9 NewTeam 2017/11/03 地点:新主楼F座二楼 任务反馈 团队成员 完成任务 计划任务 安万贺 完成了登陆退出功能Pull Request ...

  5. 69、django之Form组件

    本篇导航: 小试牛刀 Form类 常用选择插件 自定义验证规则 初始化数据 Django的Form主要具有一下几大功能: 生成HTML标签 验证用户数据(显示错误信息) HTML Form提交保留上次 ...

  6. Java 浏览器兼容模式

    现在设计的东西,很多浏览器不兼容.下面贴出代码.测试在360和IE浏览器下,可以兼容的 <!doctype html><html><head>    <met ...

  7. php将html转为图片

    在服务器端解析将编译好的html转换为图片. 由于html一般由客户端浏览器解析,服务器端不能直接解析html代码.所以我们需要借助php类库及扩展完成这一需求. 文件转换过程为 html -> ...

  8. Gotorch - 多机定时任务管理系统

    * { color: #3e3e3e } body { font-family: "Helvetica Neue", Helvetica, "Hiragino Sans ...

  9. 加密代理和Retrofit解密Converter

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

  10. 简述Handler机制

    我会对android的消息处理有三个核心类逐步介绍,他们分别是:Looper,Handler和Message.其实还有一Message Queue(消息队列),知道它是队列即可,就像我们所熟知的数组, ...