Time
limit:2000MS
Memory Limit:262144KB
64bit IO Format:%i64d &%i6 4u
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:
Program Analysis:
The main topic: Give a conformal hexagon six side length (all an integer centimeter), by parallel with the edge of the line, the question will be divided into the number of sides of a small triangle of 1
All hexagons are divided into small triangles, so the area of the hexagonal area/triangle is the number of triangles
Hexagon area: Set six side length of a[1] to a[6]
Conformal hexagon parallel to the edge, connecting two pairs of edges of the fixed point, you get a trapezoid and two triangles, the bottom of the ladder is a[4], the bottom is a[1], high by the red line of the place calculated A[3]*sin (pi/3.0) +a[2]*sin (pi/3.0), so that the area of the ladder can be calculated , the area of the remaining two triangles is a[2]*a[3]*sin (pi/3.0)/2, A[5]*a[6]*sin (pi/3.0)/2
Size of the small triangle: 1*1*sin (pi/3.0)/2.0; So the point of this topic is to find the calculation formula on the OK.
Program code:
#include<stdio.h>
double a[7] ;
int main() {
int i ;
double s ;
for(i = 1 ; i <= 6 ; i++)
scanf("%lf", &a[i]) ;
s = (a[1]+a[4])*(a[2]+a[3]) + a[2]*a[3]+ a[5]*a[6];
printf("%d\n", (int)(s+0.5)) ;
return 0 ;
}
Codeforces 559A (Gerald ' s Hexagon)