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. Maya插件开发的几种方式归纳

    目前仅仅是一时兴趣,想要探索一下Maya插件开发的具体方法,但因为没有时间所以只起了个头 首先来到Autodesk Developer Network http://usa.autodesk.com/ ...

  2. Codeforces.1051G.Distinctification(线段树合并 并查集)

    题目链接 \(Description\) 给定\(n\)个数对\(A_i,B_i\).你可以进行任意次以下两种操作: 选择一个位置\(i\),令\(A_i=A_i+1\),花费\(B_i\).必须存在 ...

  3. Java笔记(二)类

    类 一.类的基础 1.类---一种自定义数据类型. 2.与方法内创建局部变量不同,在创建对象的时候,所有的实例变量都会分配 一个默认值,这与创建数组的时候是类似的. 3.在{}对实例变量内赋值: in ...

  4. php 将时间格式 转为时间戳

    <?php $gte = "2018-08-08"; $year=((int)substr($gte,0,4));//取得年份: $month=((int)substr($g ...

  5. [洛谷P1638]逛画展

    [洛谷P1638]逛画展 题目大意: 有\(n(n\le10^6)\)个格子,每个格子有一种颜色.颜色种数为\(m(m\le2000)\).求包含所有颜色的最小区间. 思路: 尺取法裸题. 思路: # ...

  6. mongoose查询

    Model.findOne({ age:5},function(err, doc){// doc 是单个文档}); 与 findOne 相同,但它接收文档的 _id 作为参数,返回单个文档._id 可 ...

  7. BZOJ4681 : [Jsoi2010]旅行

    将边按权值从小到大排序. 考虑一条路径,一定是最大的若干条边和最小的相应的没选的边进行交换. 这会导致存在一个分界线$L$,交换之后恰好选中前$L$小的边,且只允许$>L$的边与$\leq L$ ...

  8. CCNA

  9. Django——信号

    django——signal 其实可以理解为django内部的钩子,当某一个事件发生时,其它程序会触发并对其作出相关反应,通过signal回调处理函数(receivers),从而更大程度的解耦我们的项 ...

  10. MyBatis 作用域(Scope)和生命周期

    SqlSessionFactoryBuilder SqlSessionFactoryBuilder的作用是创建SqlSessionFactory.一旦创建了SqlSessionFactory,就不再需 ...