Codeforces Round #313 (Div. 2) C. Geralds Hexagon (六边形最多划分多少个正三角形)
2015-08-13 14:24
513 查看
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
output
input
output
Note
This is what Gerald's hexagon looks like in the first sample:
And that's what it looks like in the second sample:
.
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:
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int main() { int a1,a2,a3,a4,a5,a6; int i,j,ans; while(cin>>a1>>a2>>a3>>a4>>a5>>a6) { ans=(a1+a2+a3)*(a1+a2+a3)-a1*a1-a3*a3-a5*a5; cout<<ans<<endl; } return 0; }
相关文章推荐
- HUNNU 11546 Sum of f(x)
- go语言函数例题
- Go从初学到精通遇到的问题汇总
- Google breakpad实战
- Google推荐的图片加载库Glide介绍
- 创建简单的Google地图
- OC学习笔记七 Category
- hunnu oj 11544 小明的烦恼——找字符串(字符串的最小表示法)
- Go 方法、接口
- django中出现,说template不存在的情况出现。
- django创建model
- Ubuntu下Django初体验(三)——django初体验
- Ubuntu下Django初体验(二)——创建工程及应用
- django创建一个管理员用户
- django自定义管理表单
- django用户登录和注销
- lingo解线性的缺陷
- Ubuntu下Django初体验(一)——开发环境搭建
- Aragorn's Story - HDU 3966 树链刨分
- golang 数组切片(二)