codeforces 560 C Gerald's Hexagon
神精度……………………这都能过。随便算就好了,根本不用操心
就是把六边形补全成三角形。然后去掉补的三个三角形,然后面积除以边长1的三角形的面积就可以。。。。
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#include<bitset>
#include<climits>
#include<list>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
const double pi=acos(-1.0);
double a[6];
int main()
{
for(int i=0;i<6;i++)
cin>>a[i];
double side=a[0]+a[1]+a[2],area=pow(side,2)*sin(pi/3)*cos(pi/3);
area-=pow(a[0],2)*sin(pi/3)*cos(pi/3)+pow(a[2],2)*sin(pi/3)*cos(pi/3)+pow(a[4],2)*sin(pi/3)*cos(pi/3);
double ans=area/(sin(pi/3)*cos(pi/3));
printf("%.0f",ans);
}
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:
codeforces 560 C 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 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,实际上就是求六边形面积.随便找六边形的三条互相不相邻的边,分别以这三条 ...
- 【41.43%】【codeforces 560C】Gerald's Hexagon
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【45.65%】【codeforces 560B】Gerald is into Art
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- codeforces559A--Gerald's Hexagon(计算几何)
A. Gerald's Hexagon time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
随机推荐
- Python全栈开发之16、jquery
一.查找元素 1.选择器 1.1 基本选择器 $("*") $("#id") $(".class") $("ele ...
- Linux 下开发环境的搭建(软件安装)
一.Centos6.5下安装JDK 步骤1: 查看现有安装的JDK版本 rpm –qa | grep -i java 步骤2: 卸载已有软件 rpm -e --nodeps java-1.7.0-op ...
- Ionic入门二:网格(Grid)页面布局
ionic 的网格(Grid)和其他大部分框架有所不同,它采用了弹性盒子模型(Flexible Box Model) .而且在移动端,基本上的手机都支持.row 样式指定行,col 样式指定列. 1. ...
- C#使用Pechkin与CPechkin生成PDF
http://blog.sina.com.cn/s/blog_5a52cec70102wpcf.html 1. Pechkin 从NuGet程序管理器中获得Pechkin,代码示例如下: ...
- PHP接入微信H5支付
开发前配置 进行代码接入前,需在微信后台填写授权回调域名,此域名必须经过ICP备案 开发主要流程 用户下单时选择微信支付 商户进行业务逻辑处理并调用微信统一下单接口,微信H5交易类型为:trade_t ...
- Jquery的方法(一)
一.文档操作1.内部插入:append(),appendTo(),prepend():2.外部插入:after(),before():3.删除操作:remove(),empty():4.克隆操作:cl ...
- python opencv3 视频文件的读写
git: https://github.com/linyi0604/Computer-Vision # coding:utf8 import cv2 """ 读取视频文件 ...
- [BZOJ4864][BeiJing2017Wc]神秘物质(splay)
首先merge就是先delete两次再insert,Max就是整个区间的最大值减最小值,Min就是区间中所有相邻两数差的最小值. Splay支持区间最大值,区间最小值,区间相邻差最小值即可. #inc ...
- 读书笔记_Effective_C++_条款三十七:绝不重新定义继承而来的缺省参数值
先看下面的例子: enum MyColor { RED, GREEN, BLUE, }; class Shape { public: ; }; class Rectangle: public Shap ...
- GIT(6)----fork和clone的区别,fetch与pull的区别
参考资料: [1].Git学习笔记:fork和clone的区别,fetch与pull的区别 [2].在Github和Git上fork之简单指南