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:




    题意:给出一个每一个内角都是120度的六边形,问这个六边形中能够放多少 


个边长为1的等边三角形



#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<math.h> using namespace std; int a[10];
__int64 sum; int main()
{
while(scanf("%d",&a[0])!=EOF)
{
int pt1,pt2;
sum = 0;
for(int i=1;i<6;i++)
{
scanf("%d",&a[i]);
}
int i,j;
pt1 = a[0];
i = 1;
j = 1;
while(i<=a[5] && j<=a[1])
{
sum += (pt1 * 2) + 1;
pt1 = pt1 + 1;
i++;
j++;
}
pt2 = a[3];
i = 1;
j = 1;
while(i<=a[2] && j<=a[4])
{
sum += (pt2 * 2) + 1;
pt2 = pt2 + 1;
i++;
j++;
}
if(pt2<pt1)
{
int ps = pt1;
pt1 = pt2;
pt2 = ps;
}
int pans = abs(a[2] - a[4]) + abs(a[1] - a[5]);
int pk = pt2 - pt1;
while(pt1<pt2)
{
sum += pt1 * 2 + 1;
pt1++;
}
sum += (pans - pk) * pt2;
printf("%I64d\n",sum);
}
return 0;
}

Codeforces Round #313 C. Gerald&#39;s Hexagon(放三角形)的更多相关文章

  1. Codeforces Round #313 B. Gerald is into Art(简单题)

    B. Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  2. Codeforces 559A Gerald&#39;s Hexagon 数三角形

    题意:按顺序给出一个各内角均为120°的六边形的六条边长,求该六边形能分解成多少个边长为1的单位三角形. 把单位三角形面积看做1,实际上就是求六边形面积.随便找六边形的三条互相不相邻的边,分别以这三条 ...

  3. 【打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 ...

  4. 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 ...

  5. 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 ...

  6. Codeforces Round #313 (Div. 1) Gerald&#39;s Hexagon

    http://codeforces.com/contest/559/problem/A 题目大意:按顺序给出一个各内角均为120°的六边形的六条边长,求该六边形能分解成多少个边长为1的单位三角形. 解 ...

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

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

  8. 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 ...

  9. 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 ...

随机推荐

  1. 监控慢SQL

    SELECT G.TARGET || ' ' || S.MACHINE || ' ' || ceil((G.LAST_UPDATE_TIME - G.START_TIME)*86400)   FROM ...

  2. SpringCloud学习笔记(9)----Spring Cloud Netflix之声明式 REST客户端 -Feign的使用

    1. 什么是Feign? Feign是一种声明式.模板化的HTTP客户端,在SpringCloud中使用Feign.可以做到使用HTTP请求远程服务时能与调用本地方法一样的编码体验,开发者完全感知不到 ...

  3. linux 安装常用库

    在CentOS安装软件的时候,可能缺少一部分支持库,而报错.这里首先安装系统常用的支持库.那么在安装的时候就会减少很多的错误的出现. [root@bogon 桌面]#  yum install -y ...

  4. MarkDown 图片大小问题

    本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50099843 MarkDown里显示图 ...

  5. libevent的使用(socket)

    这篇文章介绍下libevent在socket异步编程中的应用.在一些对性能要求较高的网络应用程序中,为了防止程序堵塞在socket I/O操作上造成程序性能的下降,须要使用异步编程,即程序准备好读写的 ...

  6. Java之旅(二)--- ServletContext

     什么是ServletContext?  WEB容器在启动时,它会为每一个WEB应用程序都创建一个相应的ServletContext对象.它代表当前web应用.通过使用这个对象,servlet能够 ...

  7. 12、NIO、AIO、BIO二

    一.NIO2快速读写文件 写完之后记得flush一下,NIO2不能自行创建文件,需要在文件中判断一下. package com.zxc.L; import org.junit.Test; import ...

  8. Django是什么

    Django是什么 Django是什么? 是基于python语言的优秀的web开发框架.很多有名的网站比如youtube就是用django开发的. Python写的开源Web应用框架, 快速搭建blo ...

  9. zzulioj--1804--ZY学长的密码(字符串)

    1804: ZY学长的密码 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 140  Solved: 53 SubmitStatusWeb Board ...

  10. lightoj--1155-- Power Transmission (最大流拆点)

    Power Transmission Time Limit: 2000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu Sub ...