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. IE和DOM事件流

    * ie采用冒泡型事件 Netscape使用捕获型事件 dom使用先冒泡后捕获事件 冒泡型事件模型: button->div->body (IE事件流) 捕获型事件模型: body-> ...

  2. Java并发编程(五)-- Java内存模型补充

    前面我们已经介绍了:当对象和变量存储到计算机的各个内存区域时,必然会遇到的两个问题及解决方法 共享对象的可见性-- 解决方法:使用java volatile关键字 共享对象的竞争现象 -- 解决方法: ...

  3. Django——ModuleNotFoundError: No module named 'asgiref.sync'

    Django+channels运行时报错 Unhandled exception in thread started by <function check_errors.<locals&g ...

  4. [NOIp2018提高组]赛道修建

    [NOIp2018提高组]赛道修建 题目大意: 给你一棵\(n(n\le5\times10^4)\)个结点的树,从中找出\(m\)个没有公共边的路径,使得第\(m\)长的路径最长.问第\(m\)长的路 ...

  5. (转自知乎)Unicode编码

    很多人都把Unicode编码挂在嘴边,其实咱们现实生活中遇到的编码基本都是Unicode的 因为Unicode兼容了大多数老版本的编码规范例如 ASCII Unicode编码定义了这个世界上几乎所有字 ...

  6. Docker安装管理界面portainer

    在Ubuntu或者Debian已经部署完毕Docker 拉取镜像文件: sudo docker pull docker.io/portainer/portainer Using default tag ...

  7. 考前停课集训 Day3 匪

    Day3——作死不可活的一天 Day3 今天下午才考 晚上时间少 下午网每断 因此我是PY的 然后被抓了 成绩做0分处理. 是啊,我只会抄题解. 其他什么都不会. 一无是处. 真的. 真实能力:ran ...

  8. Django——中间件设置缓存

    如图所示查看网站缓存时间 在app中创建middleware.py文件,导入MiddlewareMixin,创建类并继承MiddlewareMixin 在settings中的MIDDLEWARE=[ ...

  9. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第4章编程练习8

    #include <iostream>using namespace std;const int Size=20;struct Pizza{ char company[Size]; dou ...

  10. PAT基础6-11

    6-11 求自定类型元素序列的中位数 (25 分) 本题要求实现一个函数,求N个集合元素A[]的中位数,即序列中第⌊N/2+1⌋大的元素.其中集合元素的类型为自定义的ElementType. 函数接口 ...