CodeForces 560C Gerald's Hexagon
来源:互联网 发布:如何ping端口是否开放 编辑:程序博客网 时间:2024/05/16 05:15
CodeForces 560C
题意:给出六边形的6个边长,求其中有多少个1×1×1的小正三角形。
解题思路:最简单做法是把它补成大的三角形,然后减去三个小三角形。
我是把它分解成上中下三个部分,上下为梯形,个数为 (上底+下底)×侧长 ,若梯形的左右长度不同时还会有中间部分,个数为 下底×左右侧长度差×2。
/************************************************************************* > File Name: 0722c.cpp > Author: Narsh > > Created Time: 2016年07月22日 星期五 18时53分28秒 ************************************************************************/#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>using namespace std;int a[9];int min(int x,int y) { if (x<y) return x; return y;}int main() { for (int i = 1; i <= 6; i++) scanf("%d",&a[i]); int s=0; int d=a[1]-a[3],u=min(a[1],a[3]); if (d < 0) d=-d; s+=(a[2]*2+u)*u; u=min(a[4],a[6]); s+=(a[5]*2+u)*u; s+=(a[5]+u)*d*2; printf("%d\n",s);}
0 0
- Codeforces 560C Gerald's Hexagon(几何)
- codeforces 560 C Gerald's Hexagon
- CodeForces 560C Gerald's Hexagon
- CodeForces 560C Gerald's Hexagon
- CodeForces - 560C Gerald's Hexagon
- CodeForces 560C Gerald's Hexagon
- CodeForces 560C Gerald's Hexagon【思维】
- 【41.43%】【codeforces 560C】Gerald's Hexagon
- codeforces 560C Gerald's Hexagon(找规律)
- Codeforces 560C Gerald's Hexagon【计算几何】
- codeforces 560C Gerald's Hexagon (数学+思维)
- CodeForces#313 C. Gerald's Hexagon
- Codeforces Round #313 C. Gerald's Hexagon(放三角形)
- Codeforces Round #313 (Div. 2) C. Gerald's Hexagon 几何
- Codeforces Round #313 (Div. 2) C. Gerald's Hexagon
- Codeforces Round #313 (Div. 2) C Gerald's Hexagon 计数
- Codeforces Round #313 (Div. 2) C. Gerald's Hexagon
- Codeforces Round #313 (Div. 2)--C. Gerald's Hexagon
- npm版本更新问题(国内镜像问题)
- Jenkins服务历史记录处理
- 【杭电1789】Doing Homework again贪心(还不太懂)
- 前端开发中快速掌握的技巧
- 浅谈WEB安全性(前端向)
- CodeForces 560C Gerald's Hexagon
- Longest Common Prefix
- poj 1062 昂贵的婚礼 最短路 dijkstra 解题报告
- 以太网帧格式
- hdu 5732 subway(2016 Multi-University Training Contest 1 1010)
- POJ -3641Pseudoprime numbers(快速幂+同余定理)
- vimdiff使用
- 004-字符串分隔
- MySQL数据库的简介