Description
Gerald got a very curious hexagon for his birthday. The boy found the angles of the hexagon is equal to. Then he measured the length of their sides, and found that each of the them are 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 had got. But there were so many of them, Gerald lost the track of he counting. Help the boy count the triangles.
Input
The first and the single line of the input contains 6 space-separated integers a1, a2, a 3, a4, a5 and a6 (1≤ ai ≤ -the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed , 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, to which the hexagon is split.
Sample Input
Input
1 1 1 1 1 1
Output
6
Input
1 2 1 2 1 2
Output
13
Hint
This is what Gerald's hexagon looks like in the first sample:
And that's what's it looks like in the second sample:
The main topic: Known hexagon six side length, the number of units to be three equilateral angle. The side length is given in a clockwise order, in units of the triangle edge length
Make a hexagon into a big equilateral triangle
Finding triangles is easier
Subtract 3 small triangles from a large triangle
#include <iostream>using namespacestd;intMain () {intx[6]; while(cin>>x[0]>>x[1]>>x[2]>>x[3]>>x[4]>>x[5]) {cout<< (x[0]+x[2]+x[1]) * (x[0]+x[2]+x[1])-x[0]*x[0]-x[2]*x[2]-x[4]*x[4]<<Endl; }return 0;}
View Code
Codeforces Round #313 (Div. 2) C. Geralds Hexagon