Codeforces Round #313 (Div. 2) C. Gerald's Hexagon(补大三角形)
2 seconds
256 megabytes
standard input
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.
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.
Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.
1 1 1 1 1 1
6
1 2 1 2 1 2
13
This is what Gerald's hexagon looks like in the first sample:

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

题目链接:http://codeforces.com/contest/560/problem/C
题目大意:已知六边形的六条边长。求由多少个单位三等边角形拼成。边长按顺时针顺序给出,以单位三角形边长为单位。
解题思路:把六边形补成大等边三角形。由于边长为n的大三角形由n*n个小单位角形拼成,更easy计算。大三角形减去三个角变成六边形,减去的三个小三角形的这边长正好等于六边形中相应的的三条边长。因此,设大三角边长为s,三个小三角形边长分别为a,b,c,那个单位三角形个数为 s*s-(a*a+b*b+c*c).而 s 正好等于六边形相邻三条边之和,a。b,c 则各自等于六边形相隔的三条边,因此非常easy得出答案,能够绘图加深了解。
代码例如以下:
#include <cstdio>
#include <cstring>
int a[8];
int main()
{
int s,ans;
for(int i=0;i<6;i++)
scanf("%d",&a[i]);
s=a[0]+a[1]+a[2];
ans=s*s-(a[0]*a[0]+a[2]*a[2]+a[4]*a[4]);
printf("%d\n",ans);
return 0;
}
Codeforces Round #313 (Div. 2) C. Gerald's Hexagon(补大三角形)的更多相关文章
- Codeforces Round #313 (Div. 2) 560C Gerald's Hexagon(脑洞)
C. Gerald's Hexagon time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 【打CF,学算法——三星级】Codeforces Round #313 (Div. 2) C. Gerald's Hexagon
[CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/C 题面: C. Gerald's Hexagon time limit per tes ...
- Codeforces Round #313 (Div. 2) C. Gerald's Hexagon
C. Gerald's Hexagon time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 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的网格,让你 ...
- Codeforces Round #313 (Div. 1) A. Gerald's Hexagon
Gerald's Hexagon Problem's Link: http://codeforces.com/contest/559/problem/A Mean: 按顺时针顺序给出一个六边形的各边长 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 在Node.js中在保持目录结构的情况下压缩指定目录
最近在做一个文件升级的功能,需要从下载服务器中指定目录下的文件.在学习了zlib后发现这个模块达不到这个功能 在查找资料后发现后发现 archiver 模块很好用,不过我也发现大部分中文资料没有如果查 ...
- ARC101E - Ribbons on Tree
题目链接 ARC101E - Ribbons on Tree 题解 令边集\(S \subseteq E\) 设\(f(S)\)为边集S中没有边被染色的方案数 容斥一下,那么\(ans = \sum_ ...
- [蓝点ZigBee] Zstack 之点亮LED灯 ZigBee/CC2530 视频资料
LED点灯实验,主要是依据Zstack 现有程序修改LED相关驱动,适配到我们自己的开发板上,我们开发板共有4个LED灯,其中一个是电源指示灯,剩余3个都是GPIO控制的LED灯,有LED 灯连接方式 ...
- hihoCoder 1143 : 骨牌覆盖问题·一(递推,矩阵快速幂)
[题目链接]:click here~~ 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 骨牌,一种古老的玩具.今天我们要研究的是骨牌的覆盖问题: 我们有一个2xN的长条形 ...
- bootstrap-datetimepicker时间插件
bootstrap-datetimepicker时间插件 依赖的jar包 bootstrap的js和css jquery.js datetimepicker的js文件: bootstrap-datet ...
- CSS_选择符
2016-10-28 <CSS入门经典>第五章 以下提示注意事项: 1.如何选择使用id选择符还是class选择符:当确信id选择符在页面的唯一性时,就可以使用id选择符. 2.通用选择符 ...
- Vmware下mint os的安装
在vmware 11中,mint倒是很好安装.直接读取iso文件,会自动进入一个类似WindowsPE的安装系统,直接双击开始安装就好,比较傻瓜化. 但是安装好了,字体太小,看着很不舒服,于是就倒腾V ...
- 【小程序】小程序开发自定义组件的步骤>>>>>>>>>小程序开发过程中报错:jsEnginScriptError
报错:jsEnginScriptError VM6342: jsEnginScriptError Component is not found in path "component/spac ...
- 【linux】linux下准确查询正在tomcat下运行的java进程。准确获取正在运行的java进程的PID
准确获取定位到tomcat下正在运行的java进程的PID命令: ps -ef|grep java | grep catalina | awk '{print $2}' 准确定位到tomcat下正在运 ...
- CSS魔法堂:稍稍深入伪类选择器
前言 过去零零星星地了解和使用:link.::after和content等伪类.伪元素选择器,最近看书时发现这方面有所欠缺,于是决定稍微深入学习一下,以下为伪类部分的整理. 伪类 伪类选择器实质上 ...