codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

559A.md (1760B)


      1 Source: https://codeforces.com/problemset/problem/559/A
      2 
      3 A. Gerald's Hexagon
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to ![](https://espresso.codeforces.com/54a57cdcf7e3755ea687c12508bd83854e033ec3.png). 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.
     22 
     23 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.
     24 
     25 Input
     26 
     27 The first and the single line of the input contains 6 space-separated integers *a*1, *a*2, *a*3, *a*4, *a*5 and *a*6 (1 ≤ *a**i* ≤ 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.
     28 
     29 Output
     30 
     31 Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.
     32 
     33 Examples
     34 
     35 Input
     36 
     37 ```
     38 1 1 1 1 1 1
     39 ```
     40 
     41 Output
     42 
     43 ```
     44 6
     45 ```
     46 
     47 Input
     48 
     49 ```
     50 1 2 1 2 1 2
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 13
     57 ```
     58 
     59 Note
     60 
     61 This is what Gerald's hexagon looks like in the first sample:
     62 
     63 ![](https://espresso.codeforces.com/6e33c0f302e7beba128939cfb87fb91f0762d2b3.png)
     64 
     65 And that's what it looks like in the second sample:
     66 
     67 ![](https://espresso.codeforces.com/d3c7bbc676966585243f026b2df562e1e447e4d0.png)