Gerald ' s Hexagon
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 Test (s) input
1 1 1 1 1 1
Output
6
Input
1 2 1 2 1 2
Output
13
Address: Http://codeforces.com/contest/560/problem/C
Train of thought: Well, this problem thought for a long time, just start, want to draw a law, sub-level to find a half-day, to draw some special circumstances of the law, but there is no egg use.
Then think of the area, think of a little late, and then hit the code. The result of the 6 side of the understanding of the error, and finally wrong, so, Baidu.
maths is too poor to be able. .
There are two ways to feel:
1: Through the area to seek
Direct area: http://blog.csdn.net/winddreams/article/details/47016541
Indirect area: http://blog.csdn.net/crescent__moon/article/details/47017283
My code is to ask for area directly
#include <cstdio>using namespacestd;intMain () {intedge[6]; intT_area =1; intH_area; intCNT; while(SCANF ("%d", &edge[0]) !=EOF) { for(inti =1; I <6; i + +) {scanf ("%d", &Edge[i]); } H_area= (edge[0] + edge[3]) * (edge[1] + edge[2]) + edge[1] * edge[2] + edge[4] * edge[5]; CNT= H_area/T_area; printf ("%d\n", CNT); } return 0;}
The 2nd kind should be to find the law:
The time is more than the 2nd day to think about it and then fill it.
2015-07-27 23:47:39
Gerald ' s Hexagon