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 ...
随机推荐
- Maya插件开发的几种方式归纳
目前仅仅是一时兴趣,想要探索一下Maya插件开发的具体方法,但因为没有时间所以只起了个头 首先来到Autodesk Developer Network http://usa.autodesk.com/ ...
- BZOJ.3938.Robot(李超线段树)
BZOJ UOJ 以时间\(t\)为横坐标,位置\(p\)为纵坐标建坐标系,那每个机器人就是一条\(0\sim INF\)的折线. 用李超线段树维护最大最小值.对于折线分成若干条线段依次插入即可. 最 ...
- Max Factor 2710 最大的合数的质数因子
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2710 思路:用类似“埃氏筛法”求素数的方法 只是不在把合数标记为1 而是标记为他是因子数. 最后比较大小即 ...
- NineveGL引擎学习笔记
- JS 之 script标签
1.script标签 1.js代码的解析(包括下载js文件)会阻塞页面加载 2.当js文件放在头部,页面必须等所有js代码都被下载,解析和执行完成后才开始呈现页面内容(遇到body标签才呈现),对于那 ...
- eclipse Dynamic web module相关问题
大致因为java的web系统有多种类型,比如静态的和动态的,然后动态的java web project要设置dynamic web module,也就是动态网页模型,他必须要喝对应的服务器搭配好了才能 ...
- RMQ(Range MinimumQuery)问题之ST算法
ST算法------是用来求解给定区间RMQ的最值,本文以最小值为例 ST算法分为两部分 离线预处理(nlogn):运用DP思想,用于求解区间最值,并保存到一个二维数组中. 在线查询 (O(1)):对 ...
- 元数据管理器中存在错误。 实例化来自文件“\\?\C:\Program Files\Microsoft SQL Server\MSAS11.MSSQLSERVER\OLAP\Data\Tfs_Analysis.0.db\vDimTestCaseOverlay.874.dim.xml”的元数据对象时出错。
一.发现问题 启动SQLSERVER的数据分析服务失败 查看系统日志错误如下: 双击错误后显示详细错误: 元数据管理器中存在错误. 实例化来自文件“\\?\C:\Program Files\Micro ...
- python测试开发django-54.xadmin添加自定义页面
前言 xadmin后台如何添加一个自己写的页面呢?如果仅仅是在GlobalSettings添加url地址的话,会丢失左侧的导航菜单和顶部的页面,和整体的样式不协调. 新增页面后希望能保留原来的样式,只 ...
- SpringBoot无废话入门03:SpringMVC支持
1.默认配置 Springboot对于路径的默认位置为: spring.resources.static-locations=classpath:/META-INF/resources/,classp ...