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.
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.
Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.
1 1 1 1 1 1
6
1 2 1 2 1 2
13
This is what Gerald's hexagon looks like in the first sample:
And that's what it looks like in the second sample:
题目大意:给你六边形的边长,让你判断其中有多少个按照规律画出来的边长为1的三角形。
思路:
1、我们首先将大六边形补全变成一个正三角形。
2、然后我们用大三角形的面积减去三个补起来的小三角形的面积得到六边形的面积。
3、再然后我们直接除以边长为1的三角形的面积并且取整即可。
Ac代码:
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define ll __int64
double a[10];
const double pi=acos(-1);
int main()
{
while(~scanf("%lf%lf%lf%lf%lf%lf",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]))
{
double bian=a[0]+a[1]+a[2];
double area=(bian*bian*sin(pi/3));
area-=(a[0]*a[0]*sin(pi/3));
area-=(a[2]*a[2]*sin(pi/3));
area-=(a[4]*a[4]*sin(pi/3));
double ans=area/(sin(pi/3));
printf("%.lf\n",ans);
}
}