您的位置:首页 > 编程语言 > Go语言

codeforces-559A-Gerald's Hexagon

2015-10-31 11:58 555 查看

codeforces-559A-Gerald’s Hexagon

[code]                    time limit per test2 seconds    memory limit per test256 megabytes


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.

input

1 1 1 1 1 1

output

6

input

1 2 1 2 1 2

output

13

题目链接:cf-559A

题目大意:给出一个六边形(所有角度都是120度)的六条边长,问,里面由几个边长问1的正三角形组成。

题目思路:每个角都是120度的六边形显然可以补成正三角形,然后用正三角形的面积减去补出来的三个正三角形。

S = 1/2absinC 所以三角形个数是S(大三角形)/S(每个小三角形) 即,个数 = S边长的平方。

以下是代码:

[code]#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
using namespace std;
int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    int ans = (a + b + c) * (a + b + c) - (a * a + c * c + e * e);
    cout << ans << endl;
    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: