codeforces 559A A. Gerald's Hexagon(几何题)
2015-08-02 12:35
337 查看
题目链接:
codeforces 559A题目大意:
给出一个六边形,问它能分成几个边长为1的等边三角形题目分析:
因为给出的六边形的每个角都是120。120^。,所以如果把每个角延伸出去,那么能够得到一个等边三角形,而且延展出的三个部分都是等边三角形。我们利用等差数列得到一个等边三角形能够拆出l2l^2个边长为1的等边三角形。
-所以我们得到公式ans=(a0+a1+a2)2−a20−a22−a24 ans = (a_0+a_1+a_2)^2 - a_0^2 - a_2^2 - a_4^2
AC代码:
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int a[7]; int squre ( int x ) { return x*x; } int main ( ) { for ( int i = 0 ; i < 6 ; i++ ) scanf ( "%d" , &a[i] ); printf ( "%d\n" , squre ( a[0]+a[1]+a[2] ) - squre ( a[0] ) - squre ( a[2] ) - squre ( a[4] ) ); }
相关文章推荐
- Google黑客常用的入侵语法
- HDU 3635 Dragon Balls 带权并查集
- django notes 二:URL dispatcher
- django notes 一:开篇
- Google Play Store启用AdWords搜索广告
- poj 2762 Going from u to v or from v to u? 【判断图是否为弱连通】 【tarjan求SCC + 缩点 + 拓扑排序】
- HackerRank - "Lego Blocks"
- Django新手需要注意的10个要点
- django环境搭建
- django book学习笔记――模板
- 第三方应用如何调用google maps导航或显示某个区域的地图
- category、protocol、delegate总结
- Dragon Balls
- Argument 'xxx' is not a function, got undefined,初学Angular的第一个坑
- 小点滴——Lingo的非线性规划、最优化求解
- androd 百度地图去除logo,放大图标
- HDU 3635 Dragon Balls(并查集)
- Go 基础之数据类型、变量
- uva5318 The Goddess Of The Moon dp+矩阵快速幂
- google code jam 2009 round1 c