Codeforces Round #313 (Div. 2) C. Geralds Hexagon

Source: Internet
Author: User

Description

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 Input

Input
1 1 1 1 1 1
Output
6
Input
1 2 1 2 1 2
Output
13

Hint

This is what Gerald's hexagon looks like in the first sample:

And that's what's it looks like in the second sample:

The main topic: Known hexagon six side length, the number of units to be three equilateral angle. The side length is given in a clockwise order, in units of the triangle edge length

Make a hexagon into a big equilateral triangle

Finding triangles is easier

Subtract 3 small triangles from a large triangle

#include <iostream>using namespacestd;intMain () {intx[6];  while(cin>>x[0]>>x[1]>>x[2]>>x[3]>>x[4]>>x[5]) {cout<< (x[0]+x[2]+x[1]) * (x[0]+x[2]+x[1])-x[0]*x[0]-x[2]*x[2]-x[4]*x[4]<<Endl; }return  0;}
View Code

Codeforces Round #313 (Div. 2) C. Geralds Hexagon

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.