C. Gerald's Hexagon
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to
. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters.
There the properties of the hexagon ended and Gerald decided to draw on it.

He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his
counting. Help the boy count the triangles.

Input

The first and the single line of the input contains 6 space-separated integers
a1, a2, a3, a4, a5 and
a6 (1 ≤ ai ≤ 1000) — the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed
that the hexagon with the indicated properties and the exactly such sides exists.

Output

Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.

Sample test(s)
Input
1 1 1 1 1 1
Output
6
Input
1 2 1 2 1 2
Output
13
Note

This is what Gerald's hexagon looks like in the first sample:

And that's what it looks like in the second sample:

题目链接:http://codeforces.com/contest/560/problem/C

题目大意:已知六边形的六条边长。求由多少个单位三等边角形拼成。边长按顺时针顺序给出,以单位三角形边长为单位。

解题思路:把六边形补成大等边三角形。由于边长为n的大三角形由n*n个小单位角形拼成,更easy计算。大三角形减去三个角变成六边形,减去的三个小三角形的这边长正好等于六边形中相应的的三条边长。因此,设大三角边长为s,三个小三角形边长分别为a,b,c,那个单位三角形个数为  s*s-(a*a+b*b+c*c).而 s 正好等于六边形相邻三条边之和,a。b,c 则各自等于六边形相隔的三条边,因此非常easy得出答案,能够绘图加深了解。

代码例如以下:

#include <cstdio>
#include <cstring>
int a[8];
int main()
{
int s,ans;
for(int i=0;i<6;i++)
scanf("%d",&a[i]);
s=a[0]+a[1]+a[2];
ans=s*s-(a[0]*a[0]+a[2]*a[2]+a[4]*a[4]);
printf("%d\n",ans);
return 0;
}

Codeforces Round #313 (Div. 2) C. Gerald&#39;s Hexagon(补大三角形)的更多相关文章

  1. Codeforces Round #313 (Div. 2) 560C Gerald&#39;s Hexagon(脑洞)

    C. Gerald's Hexagon time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  2. 【打CF,学算法——三星级】Codeforces Round #313 (Div. 2) C. Gerald&#39;s Hexagon

    [CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/C 题面: C. Gerald's Hexagon time limit per tes ...

  3. Codeforces Round #313 (Div. 2) C. Gerald's Hexagon

    C. Gerald's Hexagon time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  4. 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的网格,让你 ...

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

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

  6. 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 ...

  7. Codeforces Round #313 (Div. 1) A. Gerald's Hexagon 数学题

    A. Gerald's Hexagon Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/p ...

  8. Codeforces Round #313 (Div. 2) B. Gerald is into Art 水题

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

  9. Codeforces Round #313 (Div. 1) C. Gerald and Giant Chess DP

    C. Gerald and Giant Chess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...

随机推荐

  1. Linux安装Redis和Redis基本操作命令

    01Redis简介 REmote DIctionary Server(Redis) 是一个由Salvatore Sanfilippo写的key-value存储系统. Redis是一个开源的使用ANSI ...

  2. Leetcode 记录(1~100)

    5.回文串 几种方法: 暴力:枚举每一个字串,判断是否为回文串,复杂度O(n^3),暴力月莫不可取 dp:区间dp思想,O(n^2) 中心扩展:找每一个字符,然后往两边扩展,O(n^2) manach ...

  3. HDU5293 : Tree chain problem

    问题即:选择价值和最多的链,使得每个点最多被一条链覆盖. 那么考虑其对偶问题:选择最少的点(每个点可以重复选),使得每条链上选了至少$w_i$个点. 那么将链按照LCA的深度从大到小排序,每次若发现点 ...

  4. Ural2110 : Remove or Maximize

    设最大的数为$w$,若$n>k+\log w$,那么显然所有$1$都可以保留,否则现在$n\leq k+\log w$. 如果$w\leq 100000$,那么可以DP,设$f[i][j]$表示 ...

  5. svn window下过滤文件(如配置文件等)

    第一种: 在资源管理器中,右键一个未加入版本控制文件或目录,并从弹出菜单选择TortoiseSVN →Add to Ignore List,会出现一个子菜单,允许你仅选择该文件或者所有具有相同后缀的文 ...

  6. 反编译安卓apk以及jar包

    https://www.jianshu.com/p/c9b553cf2b51 https://blog.csdn.net/bzlj2912009596/article/details/78268896

  7. 关于js函数对象的理解

    js中函数和对象的关系: 什么是对象?根据W3C上面的解释JS中所有事物都是对象,对象是拥有属性和方法的数据,由此可以看出除了基 本值类型不是对象(number.string.Boolean.Unde ...

  8. 【组合&取补集】数三角形 @CQOI2014/BZOJ3505/upcexam3843

    http://exam.upc.edu.cn/problem.php?id=3843&csrf=8oK86t2oHSgi3Q4SX3qOJGeENe6pfXri 时间限制: 1 Sec 内存限 ...

  9. Hibernate(12)_基于主键的双向1对1

    一.基于主键的双向1对1 1.介绍: 基于主键的映射策略:指一端的主键生成器使用 foreign 策略,表明根据"对方"的主键来生成自己的主键,自己并不能独立生成主键. <p ...

  10. java内部类(一)

    内部类(一) 一.定义: 内部类就是定义在另一个类内部的类,与之对应,包含内部类的类就是外部类. 二.作用: 1.内部类提供更好的封装,可以把内部类隐藏在外部类之内,不允许同一个包之中的其他类访问该类 ...