Codeforces - Round.313.Div2.C

来源:互联网 发布:商务部 融资租赁数据 编辑:程序博客网 时间:2024/05/16 15:52

C. Gerald’s Hexagon

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的正三角形去填满这个六边形,问要用到多少个小三角形

这个题可以直接求面积来求, 也可以直接补全一个大的正三角形….然而我当时却是shabi了, 想补全一个正的六边形去求……脑洞啊!智商啊!哪去了!被教育了!

#include <cmath>#include <cstdlib>#include <cstdio>#include <cstring>#include <algorithm>#include <string>#include <map>#include <vector>#include <set>#include <queue>#include <stack>#include <iostream>#define LL long long#define pb push_back#define lb lower_bound#define eps 1e-8#define INF 0x3f3f3f3fusing namespace std;int a[10];void solve(){    for(int i=0; i<6; i++) scanf("%d", &a[i]);    int ans = a[2] + a[3] + a[4];    ans *= ans;    ans -= (a[0]*a[0] + a[2]*a[2] + a[4]*a[4]);    printf("%d\n", ans);}int main(void){    #ifdef DK1        freopen("C:\\Users\\dell\\Desktop\\1.in","r",stdin);    #endif // DK    solve();    return 0;}
0 0
原创粉丝点击