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. Android Proguard

    Android Proguard 14 May 2015 语法 -include {filename} 从给定的文件中读取配置参数 -basedirectory {directoryname} 指定基 ...

  2. WEB性能测试:你应该带上VisualStudio2010

    原文地址:http://www.16aspx.com/Article/62 在Web性能测试方面,增加了循环(Loops)和条件(Conditions),让开发人员可以为他们的应用程序写出更复杂,更智 ...

  3. [Locked] Paint Fence

    Paint Fence There is a fence with n posts, each post can be painted with one of the k colors. You ha ...

  4. Mac下Intellij IDea发布Java Web项目详解五 开始测试

    测试前准备工作目录 Mac下Intellij IDea发布Web项目详解一 Mac下Intellij IDea发布Java Web项目(适合第一次配置Tomcat的家伙们)详解二 Mac下Intell ...

  5. openStack controller 管理网口TX数据量非常大 网络总是丢包

  6. [转载]软件测试之Web测试经典总结

    转载自:软件测试之Web测试经典总结 基于Web的系统测试在基于Web的系统开发中,如果缺乏严格的过程,我们在开发.发布.实施和维护Web的过程中,可能就会碰到一些严重的问题,失败的可能性很大.而且, ...

  7. selenium grid 搭建

    hub端 Step1: 下载 selenium-server-standalone-x.xx.x.jar我下载的是:selenium-server-standalone-2.44.0.jar下载地址: ...

  8. <一>初探js特效魅力之全选不选反选04

    初探js特效魅力04 我们在进入到公司里面工作的时候,做一个同一个项目,经常是大家分工合作,当我们写css时,一般不写在行间,因为这样会被误操作,也就是被乱删了都不知道,这样的后果是很难检查的 ,因为 ...

  9. QQ群成员提取

    var ids = document.querySelectorAll(".member_id"); var names = document.querySelectorAll(& ...

  10. solr 在windows下的安装

    安装环境 Windows 7 64bit Apache-tomcat-8.0.9-windows-x64 Solr-4.9.0 JDK 1.8.0_05 64bit 安装步骤 Tomcat和JDk的安 ...