O - 计数

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

 

Description

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 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 it looks like in the second sample:

题解;又是一道数学问题,输入六边形的每条边的长度,然后以边长1画等边三角形,统计六边形内部三角形的个数,统计时采用容斥原理即可。

盗图一张。。

这里输入的边长为3 4 2 6 1 5   ,通过填补的到一个正三角形,正三角形的边长len就是前三个边a1+a2+a3=9,这个正三角形中含有边长为1的三角形的个数就是len*len=81,然后减去三个角的三角形个数即可,这三个三角形也是正三角形,所以减去的三角形个数就是3*3+2*2+1*1,所以六边形含有的边长为1的三角形个数为81-(3*3+2*2+1*1)=67

代码:

#include<iostream>
using namespace std;
int main()
{
int a1,a2,a3,a4,a5,a6;
cin>>a1>>a2>>a3>>a4>>a5>>a6;
int len=a1+a2+a3;
cout<<len*len-a1*a1-a3*a3-a5*a5<<endl;
}

第六周O题(等边三角形个数)的更多相关文章

  1. hdu 4548 第六周H题(美素数)

    第六周H题 - 数论,晒素数 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   De ...

  2. 程序设计入门—Java语言 第六周编程题 1 单词长度(4分)

    第六周编程题 依照学术诚信条款,我保证此作业是本人独立完成的. 1 单词长度(4分) 题目内容: 你的程序要读入一行文本,其中以空格分隔为若干个单词,以'.'结束.你要输出这行文本中每个单词的长度.这 ...

  3. Codeforces 559A 第六周 O题

    Description Gerald got a very curious hexagon for his birthday. The boy found out that all the angle ...

  4. 第六周 N题

    Description As Harry Potter series is over, Harry has no job. Since he wants to make quick money, (h ...

  5. hdu1405 第六周J题(质因数分解)

    J - 数论,质因数分解 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Desc ...

  6. 集训第六周 O题

    Description Gerald got a very curious hexagon for his birthday. The boy found out that all the angle ...

  7. 第六周 E题 期望.....

    Description Given a dice with n sides, you have to find the expected number of times you have to thr ...

  8. HDU 1465 第六周L题

    Description 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了!  做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的道理一样.  ...

  9. HDU 1405 第六周 J题

    Description Tomorrow is contest day, Are you all ready?  We have been training for 45 days, and all ...

随机推荐

  1. Codeforces Round #333 (Div. 1)--B. Lipshitz Sequence 单调栈

    题意:n个点, 坐标已知,其中横坐标为为1~n. 求区间[l, r] 的所有子区间内斜率最大值的和. 首先要知道,[l, r]区间内最大的斜率必然是相邻的两个点构成的. 然后问题就变成了求区间[l, ...

  2. Piotr's Ants UVa 10881

    #include <cstdio> #include <cmath> #include <algorithm> #include <iostream> ...

  3. ServletConfig

    ServletConfig Servlet配置 比如web程序中的某一个Servlet需要配置一些初始化信息,需要在web.xml中进行配置 <servlet> <servlet-n ...

  4. ubuntu忘记密码

    Do these two things just to make sure: mount -o remount,rw / This first part remounts the root parti ...

  5. 表格布局TableLayout

    简单实现计算机界面布局的案例: <?xml version="1.0" encoding="utf-8"?><TableLayout xmln ...

  6. GS1已分配给国家(地区)编码组织的前缀码

    前缀码即商品条码(EAN-13或者EAN-8)的前三位,其代表的是一个国家和地区,由此前缀可查出所购买的商品是出产自哪个国家的. 下表列出了GS1已分配给国家(地区)编码组织的前缀码 前缀码 管理的国 ...

  7. struts2入门程序

    struts2入门程序 1.示例 搭建编程环境就先不说了,这里假设已经搭建好了编程环境,并且下好了strut2的jar包,接下来程序. 1.1 新建web项目 点击File->New->D ...

  8. Ternary Search Tree 应用--搜索框智能提示

    前面介绍了Ternary Search Tree和它的实现,那么可以用Ternary Search Tree来实现搜索框的只能提示,因为Ternary Search Tree的前缀匹配效率是非常高的, ...

  9. TCP/IP协议原理与应用笔记07:HTTP、TCP/IP与socket区别

    1. TCP/IP协议与HTTP协议区别:      HTTP 超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议.所有的WWW文件 ...

  10. Android中使用HttpGet和HttpPost访问HTTP资源

    需求:用户登录(name:用户名,pwd:密码) (一)HttpGet :doGet()方法//doGet():将参数的键值对附加在url后面来传递 public String getResultFo ...