【打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 ...
随机推荐
- ORACLE使用数据泵导入导出部分表
1.导出名字为A的表(这里会导出SEQUENCES及FUNCTION等内容) expdp TEST/TEST@orcl schemas=TEST dumpfile=TEST.dmp DIRECTORY ...
- Nginx-动态路由升级版
前几篇文章我们介绍了Nginx的配置.OpenResty安装配置.基于Redis的动态路由以及Nginx的监控. Nginx-OpenResty安装配置 Nginx配置详解 Nginx技术研究系列1- ...
- 我在学JavaScript中的循环
for (var num1 = 1;num1 < 10;num1++ ){ for (var num2 = 1;num2< 10;num2++ ){ console.log(num1+'* ...
- 10个鲜为人知的C#关键字
在正式开始之前,我需要先声明:这些关键字对于偏向底层的程序员更加耳熟能详,对这些关键字不了解并不影响你作为一个合格的程序员. 这意味着这些关键字会让你在编写程序时得到更好的代码质量和可读性,enjoy ...
- [转载] java的动态代理机制详解
转载自http://www.cnblogs.com/xiaoluo501395377/p/3383130.html 代理模式 代理模式是常用的java设计模式,他的特征是代理类与委托类有同样的接口,代 ...
- selenium3.7+ python3 添加cookie模拟登陆
一.背景介绍 最近做一个爬虫项目,用selenium调用浏览器去获取渲染后的源码,但是每次登陆都需要手机验证,这真的是头痛啊,这种验证方式不要想着去破解,还是老老实实用手机收验证码去吧!反正我是不知道 ...
- [转]Oracle 创建 DBLink 的方法
http://blog.csdn.net/davidhsing/article/details/6408770 1.如果需要创建全局 DBLink,则需要先确定用户有创建 dblink 的权限: 如果 ...
- 准备冲锋 golang入坑系列
史前摘要: 本来想写读前必读,但连续几篇博文都写读前必读,感觉就没有了新意. 所以换成史前摘要,反正是一个意思. 此摘要的目的仍然是提醒点击而来的同学,本系列最新文章在这里.放到博客园的目的是为了方便 ...
- Orchard Core一分钟搭建ASP.NET Core CMS
Orchard Core 是Orchard CMS的ASP.NET Core版本. Orchard Core是全新一代的ASP.NET Core CMS. 官方文档介绍:http://orchardc ...
- Python 日志处理(一) 按Nginx log_format 分割日志记录
要求:不使用正则 根据nginx 默认的日志记录格式,分割日志记录. log_format main '$remote_addr - $remote_user [$time_local] " ...