【打CF,学算法——三星级】Codeforces Round #313 (Div. 2) C. Gerald's Hexagon
提交链接:http://codeforces.com/contest/560/problem/C
题面:
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 integersa1, a2, a3, a4, a5
anda6 (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
解题:
画着画着发现。每个六边形能够用相邻两条边构成的平行四边形切割,有些情况恰能够切割,有些不可,中间存在一个三角形。
不能够的是,相隔2条的边的边长之差不为0。
然后依据这个差。就能够算出中间还有几个未切割的三角形。
代码:
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
int a,b,c,d,e,f,sum,ans;
sum=ans=0;
scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
ans+=2*(a*b+c*d+e*f);
sum=abs(a-d);
sum=sum*sum;
ans+=sum;
printf("%d\n",ans);
return 0;
}
【打CF,学算法——三星级】Codeforces Round #313 (Div. 2) C. Gerald's Hexagon的更多相关文章
- 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 ...
- 【打CF,学算法——二星级】Codeforces Round #313 (Div. 2) B. Gerald is into Art(水题)
[CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/B 题面: B. Gerald is into Art time limit per t ...
- 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. 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) C. Gerald and Giant Chess
这场CF又掉分了... 这题题意大概就给一个h*w的棋盘,中间有一些黑格子不能走,问只能向右或者向下走的情况下,从左上到右下有多少种方案. 开个sum数组,sum[i]表示走到第i个黑点但是不经过其他 ...
- Codeforces Round #313 (Div. 2) E. Gerald and Giant Chess (Lucas + dp)
题目链接:http://codeforces.com/contest/560/problem/E 给你一个n*m的网格,有k个坏点,问你从(1,1)到(n,m)不经过坏点有多少条路径. 先把这些坏点排 ...
- 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 ...
随机推荐
- php正则表达式,在抓取内容进行匹配的时候表现不稳定
最近做了一个 抓取内容的程序,使用php的正则表达式对抓取的内容进行匹配,当进行大量匹配运算的时候,发现偶尔会出现匹配失败的情况.检查不出任何原因. 匹配失败导致匹配结果为空,最终导致写入数据库失败. ...
- struts2中struts.xml配置文件详解
struts.xml的常用配置 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts ...
- VS2015如何连接mySQL数据库图文
1.新建一个工程名叫mysql,编程环境选择c#,然后选择windows窗体应用程序,新建一个窗体用于显示查询到sql数据库的数据集 2.从工具箱向form1窗体上拖一个按钮和datagridview ...
- C#多功能DataGridView打印类(WinForm)
; printPreviewDialog.ShowDialog(); } catch { ...
- 前端面试题(6)图片格式jpg,gif,png-8,png-24的区别,及其各自的使用场景
Gif格式特点: 透明性,Gif是一种布尔透明类型,既它可以是全透明,也可以是全不透明,但是它并没有半透明(alpha透明). 动画,Gif这种格式支持动画. 无损耗性,Gif是一种无损耗的图像格式, ...
- linux expect自动登陆远程服务器 批量管理服务器
#!/usr/bin/expect set ipaddress [lindex $argv 0] set passwd [lindex $argv 1] set timeout 3 spawn ssh ...
- 使用canvas绘制时钟 (http://heeroluo.net/Article/Detail/95)
准备工作 在HTML中指定一个区域放置时钟: <div id="clock" style="position: relative;"></di ...
- MATLAB 大数据剔除坏值
在用MATLAB进行数据分析的时候,坏点对正确结果的影响比较大, 因此,我么需要剔除野点,对于坏值的剔除,我们 利用 3σ准则 剔除无效数据: 3σ准则又称为拉依达准则,它是先假设一组检测数据只含有 ...
- (一)windows7下solr7.1.0默认jetty服务器环境搭建
windows7下solr7.1.0默认jetty服务器环境搭建 1.下载solr solr7官网地址:http://lucene.apache.org/solr/ jdk8官网地址:http://w ...
- struts2对于处理JSON的配置
由于最近几年日益流行前后端分离模式,JSON作为数据载体也变得不可或缺.几乎所有的web框架都需要支持JSON,下面咱就一起了解下struts2是如何支持JSON的. 对于JSON的发送 这里有两种方 ...