C. Gerald's Hexagon
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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
Note

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

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

解:

取不相邻的三条边以边长向外即可扩展成一个大等边三角形,因为边长为n的大三角形由n*n个小单位角形拼成,更容易计算。,再减去补上的三角形面积。

这是我搜的题解,补的方法很巧妙。

#include <cstdio>
#include <iostream>
#include <algorithm>
#define N 1000005
using namespace std; int main()
{
int a[];
for(int i = ; i < ; i++) scanf("%d", &a[i]);
printf("%d", (a[] + a[] + a[]) * (a[] + a[] + a[]) - (a[] *a[] + a[] * a[] + a[] * a[]));
return ;
}

Codeforces Round #313 (Div. 2) C. Gerald's Hexagon的更多相关文章

  1. Codeforces Round #313 (Div. 1) A. Gerald's Hexagon

    Gerald's Hexagon Problem's Link: http://codeforces.com/contest/559/problem/A Mean: 按顺时针顺序给出一个六边形的各边长 ...

  2. Codeforces Round #313 (Div. 2) C. Gerald's Hexagon 数学

    C. Gerald's Hexagon Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/pr ...

  3. Codeforces Round #313 (Div. 1) A. Gerald's Hexagon 数学题

    A. Gerald's Hexagon Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/p ...

  4. 【打CF,学算法——三星级】Codeforces Round #313 (Div. 2) C. Gerald&#39;s Hexagon

    [CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/C 题面: C. Gerald's Hexagon time limit per tes ...

  5. Codeforces Round #313 (Div. 2) C. Gerald&#39;s Hexagon(补大三角形)

    C. Gerald's Hexagon time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  6. Codeforces Round #313 (Div. 2) 560C Gerald&#39;s Hexagon(脑洞)

    C. Gerald's Hexagon time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. dp - Codeforces Round #313 (Div. 1) C. Gerald and Giant Chess

    Gerald and Giant Chess Problem's Link: http://codeforces.com/contest/559/problem/C Mean: 一个n*m的网格,让你 ...

  8. Codeforces Round #313 (Div. 2) B. Gerald is into Art 水题

    B. Gerald is into Art Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/560 ...

  9. Codeforces Round #313 (Div. 1) C. Gerald and Giant Chess DP

    C. Gerald and Giant Chess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...

随机推荐

  1. SQL判断临时表是否存在

    IF EXISTS(select * from tempdb..sysobjects where id=object_id('tempdb..#tb')) BEGIN DROP TABLE #tb E ...

  2. implement Google's Open Source Slam "Cartographer" demos in ROS/rviz

    Cartographer is a backpack equipped with Simultaneous Localization and Mapping (SLAM) technology. 1. ...

  3. jQuery:show()方法

    show()方法是jQuery的方法,功能是显示元素,参数是时间,单位是毫秒,例如: Html: <div class="one" id="one"> ...

  4. Linux下C程序的编译,运行,及调试

    先查看linux有没有gcc 和 gdb $ gcc -v $ gdb -v 如果没有安装gcc,可以 $ yum install gcc 要获取管理员权限才能安装软件,$ su root (有的li ...

  5. [转载] C++ 多线程编程总结

    原文: http://www.cnblogs.com/zhiranok/archive/2012/05/13/cpp_multi_thread.html 在开发C++程序时,一般在吞吐量.并发.实时性 ...

  6. Promise A 规范的一个简单的浏览器端实现

    简单的实现了一个promise 的规范,留着接下来模块使用.感觉还有很多能优化的地方,有时间看看源码,或者其他大神的代码 主要是Then 函数.回调有点绕人. !(function(win) { fu ...

  7. Python学习(16)File(文件)方法

    Python File(文件) 方法 file 对象使用 open 函数来创建,下表列出了 file 对象常用的函数: 序号 方法及描述 1 file.close() 关闭文件.关闭后文件不能再进行读 ...

  8. Monkey学习(1)环境搭建

    环境搭建: Monkey程序由Android系统自带,需要配置J2SE平台的JDK,还需要配置Android平台的SDK. 1)下载和配置JDK 下载与安装JDK过程省略... 配置JDK环境变量,我 ...

  9. ES6中的const命令

      1.const声明一个只读常量,一旦声明,常量的值就不能改变 1 const PI=3.1415; 2 console.log(PI);//3.1415 3 4 PI=3;//Uncaught T ...

  10. pod JONSKit.h MBProgress.h 找不到头文件,怎么办?

    这时你看项目pod部分,多了JSONKit库.好了,第三方库就这么神奇的加进来. 头文件路径 那试试看使用JONSKit.h,在ViewController.m里引用下.找不到头文件,怎么办?还没设置 ...