Codeforces Round #313 (Div. 2) C. Gerald's Hexagon
来源:互联网 发布:商务部 融资租赁数据 编辑:程序博客网 时间:2024/06/05 06:31
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
因为是在正六边形的基础上形成的这个六边形,所以这个六边形的第二条边加上第三条边等于第五条边加上第六条边,所以可以把这六边形补成一个梯形,然后把多余的部分面积减去,因为是在算面积,所以最后不要忘了除以边长为1的三角形面积,然后就可以得到小三角形的面积了。
#include<iostream>#include<stdio.h> #include<math.h>using namespace std;int main(){double a[6];for(int i=0;i<6;i++) cin>>a[i];double sum=0;double size=0;double high=0;high=(sqrt(3)/2)*(a[1]+a[2]);sum=(a[0]+a[3]+a[2]+a[4])*high/2;double little1=0;double little2=0;little1=sqrt(3)*a[2]*a[2]/4;little2=sqrt(3)*a[4]*a[4]/4;double area=0;area=(sum-little1-little2)/(sqrt(3)/4);printf("%.0lf\n",area);return 0;}
- Codeforces Round #313 (Div. 2) C. Gerald's Hexagon 几何
- Codeforces Round #313 (Div. 2) C. Gerald's Hexagon
- Codeforces Round #313 (Div. 2) C Gerald's Hexagon 计数
- Codeforces Round #313 (Div. 2) C. Gerald's Hexagon
- Codeforces Round #313 (Div. 2)--C. Gerald's Hexagon
- Codeforces Round #313 (Div. 2) Gerald's Hexagon
- Codeforces Round #313 (Div. 2) Gerald's Hexagon
- 【打CF,学算法——三星级】Codeforces Round #313 (Div. 2) C. Gerald's Hexagon
- Codeforces Round #313 (Div. 2) C. Gerald's Hexagon(补大三角形)
- Codeforces Round #313 (Div. 2) 560C Gerald's Hexagon(脑洞)
- Codeforces Round #313 (Div. 1) Gerald's Hexagon
- Codeforces Round #313 (Div. 1) A. Gerald's Hexagon
- Codeforces Round #313 C. Gerald's Hexagon(放三角形)
- Codeforces Round 313- Gerald's Hexagon
- Codeforces Round #313 (Div. 2)-Gerald's Hexagon 找规律-几何规律-
- CodeForces#313 C. Gerald's Hexagon
- Codeforces Round #313 Gerald's Hexagon (数论)
- Codeforces 560C Gerald's Hexagon(几何)
- 详解jar命令打包生成双击即可运行的Java程序
- [Leetcode 239, Hard] Sliding Window Maximum
- Codeforces - Round.313.Div2.C
- Reverse Linked List II
- 一个简单的人脸检测
- Codeforces Round #313 (Div. 2) C. Gerald's Hexagon
- 2015年7月23日20:22:09
- 数据库分组函数
- perl中默认的变量介绍
- MyBatis第一天
- 十分钟搞定pandas
- MM眉心为什么会长痘痘
- 行编辑程序
- Java容器类