codeforces559A--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的小三角形
六边形的所有都被分为了小三角形,所以用六边形的面积/三角形的面积就是三角形的数量
六边形的面积:设六条边长为a[1]到a[6]
等角六边形的对边平行,连接两个对边的定点,就得到一个梯形和两个三角形。梯形的上底是a[4],下底是a[1]。高由划红线的地方算出a[3]*sin(PI/3.0)+a[2]*sin(PI/3.0),这样就能够算出梯形的面积,其余的两个三角形的面积为a[2]*a[3]*sin(PI/3.0)/2。 a[5]*a[6]*sin(PI/3.0)/2
小三角形的面积:1*1*sin(PI/3.0)/2.0 ;
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std ;
#define LL __int64
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
double a[7] ;
int main() {
int i ;
double l , s ;
for(i = 1 ; i <= 6 ; i++)
scanf("%lf", &a[i]) ;
s = (a[1]+a[4])*(a[2]+a[3]) + a[2]*a[3]+ a[5]*a[6];
printf("%d\n", (int)(s+0.5)) ;
return 0 ;
}
codeforces559A--Gerald's Hexagon(计算几何)的更多相关文章
- 【打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 560 C Gerald's Hexagon
神精度--------这都能过.随便算就好了,根本不用操心 就是把六边形补全成三角形.然后去掉补的三个三角形,然后面积除以边长1的三角形的面积就可以.... #include<map> # ...
- Codeforces Round #313 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 ...
- Codeforces Round #313 (Div. 1) Gerald's Hexagon
http://codeforces.com/contest/559/problem/A 题目大意:按顺序给出一个各内角均为120°的六边形的六条边长,求该六边形能分解成多少个边长为1的单位三角形. 解 ...
- Codeforces 559A Gerald's Hexagon 数三角形
题意:按顺序给出一个各内角均为120°的六边形的六条边长,求该六边形能分解成多少个边长为1的单位三角形. 把单位三角形面积看做1,实际上就是求六边形面积.随便找六边形的三条互相不相邻的边,分别以这三条 ...
- Gerald's Hexagon
Gerald's Hexagon Gerald got a very curious hexagon for his birthday. The boy found out that all the ...
- Codeforces Round #313 (Div. 1) A. Gerald's Hexagon
Gerald's Hexagon Problem's Link: http://codeforces.com/contest/559/problem/A Mean: 按顺时针顺序给出一个六边形的各边长 ...
随机推荐
- bzoj [Noi2008] 1061 志愿者招募 单纯形
[Noi2008]志愿者招募 Time Limit: 20 Sec Memory Limit: 162 MBSubmit: 5437 Solved: 3267[Submit][Status][Di ...
- RHN Classic and Red Hat Subscription Management
What's the difference between RHN Classic and Red Hat Subscription Management? Introduction With the ...
- Linux下的ACL
ACL理论概述 9位的属主/属组/其他人访问控制系统已经得到证明是强大的,足以满足大多数管理方面的需求. 事实上,在所有非UNIX操作系统上都采用了一种实质上更为复杂的方式来管理对于文件的访问:访问控 ...
- webapp的favicon应该怎样组织代码
处理过那么多index 页面了那么关于特别针对于此页的favicon是时候详细的总结一下了 它是网站的头像,它出现在浏览器的收藏夹中(标题的旁边) ,浏览器标签页的左上角,微信公众号的logo,保存网 ...
- 汕头市队赛 SRM 09 C 撕书
C 撕书III-3 SRM 09 背景&&描述 琉璃双在撕书. 书总共有n页,每页都可以看作是一个数字. 琉璃读书喜欢来回地读.但他也因此发现了作者的灌水行为:有些连续 ...
- HDU 3389 Game (阶梯博弈)
Game Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Submit Status D ...
- ios手机弹出层上表单的操作,收起键盘焦点错乱的问题
今天遇到了ios手机下 弹出层上form表单 当收起键盘后,焦点错乱,无法再操作的问题 解决办法 function device() { const u = navigator.userAgent; ...
- (转)cygwin包管理器apt-cyg
通过终端安装apt-cyg之前选要安装以下软件包 wget tar gawk bzip2 Cygwin终端安装 wget http://apt-cyg.googlecode.com/svn/trunk ...
- TMS320F28379D 使用心得之 SCI
原文地址https://blog.csdn.net/qq_39545674/article/details/82597106 一.SCI 简介SCI(Serial Communication Inte ...
- linux 内核库函数 【转】
转自:http://blog.chinaunix.net/uid-20321537-id-1966892.html 当编写驱动程序时,一般情况下不能使用C标准库的函数.Linux内核也提供了与标准库函 ...