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:

解:
取不相邻的三条边以边长向外即可扩展成一个大等边三角形,因为边长为n的大三角形由n*n个小单位角形拼成,更容易计算。,再减去补上的三角形面积。
这是我搜的题解,补的方法很巧妙。
#include <cstdio>
#include <iostream>
#include <algorithm>
#define N 1000005
using namespace std; int main()
{
int a[];
for(int i = ; i < ; i++) scanf("%d", &a[i]);
printf("%d", (a[] + a[] + a[]) * (a[] + a[] + a[]) - (a[] *a[] + a[] * a[] + a[] * a[]));
return ;
}
Codeforces Round #313 (Div. 2) C. Gerald's Hexagon的更多相关文章
- 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 ...
- 【打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 ...
- 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 ...
- 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. 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 ...
随机推荐
- eclipse注释模板
设置注释模板的入口: Window->Preference->Java->Code Style->Code Template 然后展开Comments节点就是所有需设置注释的元 ...
- php工具 phpstorm 的快捷键 的使用(待添加
参考网址:http://www.cnblogs.com/jikey/p/3491798.html 1. ctrl+tab 键,可以切换各个选项卡 页面 2. shift+enter 键,无论光标在本行 ...
- android的简单入门学习
话说光配环境就整死我了, 不是说多么难, 是最近google被屏了, 很多sdk里面需要下载的东西都下不下来, 坑爹啊. 最后跟扫拉稀要了一个他配置好的,才运行了. android目录分析: ass ...
- 强制性签出被人没有签入的文件(在.net开发vs中)
灵感,是天才的女神.她并不步履蹒跚地走过,而是在空中像乌鸦那么警觉地飞过的,她没有什么剽带给诗人抓握,她的头是一团烈火,她溜得快,像那些白里带红的鹤,教猎人见了无可奈何.——巴尔扎克(上海网站建设) ...
- PL/SQL 编写规范
大小写风格 所有数据库关键字和保留字均大写; 缩进风格 使用空格, 缩进2格(前边空两个格, 后边要与SQL语句的一致, 比如下面:) SELECT * FROM TABLE 空格及换行 1行只写1条 ...
- js输出26个字母两种方法(js fromCharCode的使用)
方法一 var character = new Array("A","B","C","D","E", ...
- jquery定位
1.$("div").offset().left ; div到文档的左距离(offset() 方法返回或设置匹配元素相对于文档的偏移) $("div").off ...
- C# Socket编程(5)使用TCP Socket
TCP 协议(Transmission Control Protocol,传输控制协议)是TCP/IP体系中面向连接(connection oriented)的传输层(transport layer) ...
- 出现Warning:Gradle version 2.10 is required. Current version is 2.8.
Warning:Gradle version 2.10 is required. Current version is 2.8. If using the gradle wrapper, try ed ...
- iOS开发 差间距滚动
CGFloat fView_Height(UIView *aView) { return aView.frame.size.height; } CGFloat fView_Width(UIView * ...