Codeforces Round #313 (Div. 2) C. Gerald's Hexagon
2015-07-23 20:25
656 查看
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
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
![](http://codeforces.com/predownloaded/dc/7b/dc7bf370dd61f03eda680c0d25e2b2944ef11290.png)
.
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.
Input
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.
Output
Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.
Sample test(s)
input
output
input
output
这道题的意思是按顺时针给出六边形的六条边,计算这六边形里有多少个边长为1的三角形,当然,这个六边形是在正六边形的基础上增加其边长的。
因为是在正六边形的基础上形成的这个六边形,所以这个六边形的第二条边加上第三条边等于第五条边加上第六条边,所以可以把这六边形补成一个梯形,然后把多余的部分面积减去,因为是在算面积,所以最后不要忘了除以边长为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(
4000
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;
}
2 seconds
memory limit per test
256 megabytes
input
standard input
output
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
![](http://codeforces.com/predownloaded/dc/7b/dc7bf370dd61f03eda680c0d25e2b2944ef11290.png)
.
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.
Input
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.
Output
Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.
Sample test(s)
input
1 1 1 1 1 1
output
6
input
1 2 1 2 1 2
output
13
这道题的意思是按顺时针给出六边形的六条边,计算这六边形里有多少个边长为1的三角形,当然,这个六边形是在正六边形的基础上增加其边长的。
因为是在正六边形的基础上形成的这个六边形,所以这个六边形的第二条边加上第三条边等于第五条边加上第六条边,所以可以把这六边形补成一个梯形,然后把多余的部分面积减去,因为是在算面积,所以最后不要忘了除以边长为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(
4000
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 #197 (Div. 2)
- Codeforces Round #198 (Div. 1)
- Codeforces 405E Codeforces Round #238 (Div. 2)E
- Codeforces 407C Codeforces Round #239 (Div. 1)C
- CodeForces 449A - Jzzhu and Chocolate
- CodeForces 449 B. Jzzhu and Cities
- Codeforces Round #265 (Div. 2)
- Codeforces #310 div2 C. Case of Matryoshkas
- 状态压缩DP codeforces 244 Problem C. The Brand New Function 和 codeforces 165 E. Compatible Numbers
- codeforces 16 Problem E fish
- Codeforces round #247 for Div. 2
- Codeforces Round #246 (Div. 2)
- Codeforces #264(div 2)D.Gargari and Permutations
- Codeforces Round #236 (Div. 2)------A,B
- codeforces 257 div2 B
- Codeforces Div2 244AB
- Coder-Strike 2014 - Finals (online edition, Div. 2)AB
- Codeforces Div2 243AB
- Codeforces Div2 242AB
- Codeforces 193 Div 2