Gerald's Hexagon
Crawlingin process... Crawling failed Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Submit Status
Description
Gerald got a very curious hexagon for his birthday. The boyfound 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. Therethe properties of the hexagon ended and Gerald decided to draw on it.
He painted a few lines, parallel to the sides of thehexagon. The lines split the hexagon into regular triangles with sides of 1centimeter. Now Gerald wonders how many triangles he has got. But there were somany of them that Gerald lost the track of his counting. Help the boy count thetriangles.
Input
The first and the single line of the input contains 6space-separated integers a1,a2,a3,a4,a5 and a6 (1≤ai≤1000) — the lengths of thesides of the hexagons in centimeters in the clockwise order. It is guaranteedthat the hexagon with the indicated properties and the exactly such sidesexists.
Output
Print a single integer — the number of triangles with thesides of one 1 centimeter, into 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
Sample Output
1
2
Hint
This is what Gerald's hexagon looks like in the firstsample:
And that's what it looks like in the second sample:
Crawlingin process... Crawling failed Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Submit Status
Description
Gerald got a very curious hexagon for his birthday. The boyfound 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. Therethe properties of the hexagon ended and Gerald decided to draw on it.
He painted a few lines, parallel to the sides of thehexagon. The lines split the hexagon into regular triangles with sides of 1centimeter. Now Gerald wonders how many triangles he has got. But there were somany of them that Gerald lost the track of his counting. Help the boy count thetriangles.
Input
The first and the single line of the input contains 6space-separated integers a1,a2,a3,a4,a5 and a6 (1≤ai≤1000) — the lengths of thesides of the hexagons in centimeters in the clockwise order. It is guaranteedthat the hexagon with the indicated properties and the exactly such sidesexists.
Output
Print a single integer — the number of triangles with thesides of one 1 centimeter, into 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
Sample Output
1
2
Hint
This is what Gerald's hexagon looks like in the firstsample:
And that's what it looks like in the second sample: