Codeforces Round #313 (Div. 2) C. Gerald's Hexagon

来源:互联网 发布:商务部 融资租赁数据 编辑:程序博客网 时间:2024/06/05 06:31
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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
1 1 1 1 1 1
output
6
input
1 2 1 2 1 2
output
13
这道题的意思是按顺时针给出六边形的六条边,计算这六边形里有多少个边长为1的三角形,当然,这个六边形是在正六边形的基础上增加其边长的。

因为是在正六边形的基础上形成的这个六边形,所以这个六边形的第二条边加上第三条边等于第五条边加上第六条边,所以可以把这六边形补成一个梯形,然后把多余的部分面积减去,因为是在算面积,所以最后不要忘了除以边长为1的三角形面积,然后就可以得到小三角形的面积了。

#include<iostream>#include<stdio.h> #include<math.h>using namespace std;int main(){double a[6];for(int i=0;i<6;i++)  cin>>a[i];double sum=0;double size=0;double high=0;high=(sqrt(3)/2)*(a[1]+a[2]);sum=(a[0]+a[3]+a[2]+a[4])*high/2;double little1=0;double little2=0;little1=sqrt(3)*a[2]*a[2]/4;little2=sqrt(3)*a[4]*a[4]/4;double area=0;area=(sum-little1-little2)/(sqrt(3)/4);printf("%.0lf\n",area);return 0;}




0 0
原创粉丝点击