Codeforces 559A 第六周 O题
Description
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.
Input
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.
Output
Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.
Sample Input
1 1 1 1 1 1
6
1 2 1 2 1 2
13
Hint
This is what Gerald's hexagon looks like in the first sample:
And that's what it looks like in the second sample:
题意:按顺序给出一个各内角均为120°的六边形的六条边长,求该六边形能分解成多少个边长为1的单位三角形。
题解:把六边形补全为一个三角行,然后求出这个三角形可以分成的边长为1的等边三角形的个数再减去刚刚补上的那部分(也就是那三个小三角形)
这里的关键就是等边三角形由小三角形组成的个数是n*n,这里的n是边长......
代码如下:
#include <stdio.h>
int main()
{
int b1,b2,b3,b4,b5,b6;
scanf("%d%d%d%d%d%d",&b1,&b2,&b3,&b4,&b5,&b6);
int ans=(b2+b3+b4)*(b2+b3+b4)-(b2*b2+b4*b4+b6*b6);
printf("%d\n",ans);
return ;
}
Codeforces 559A 第六周 O题的更多相关文章
- 程序设计入门—Java语言 第六周编程题 1 单词长度(4分)
第六周编程题 依照学术诚信条款,我保证此作业是本人独立完成的. 1 单词长度(4分) 题目内容: 你的程序要读入一行文本,其中以空格分隔为若干个单词,以'.'结束.你要输出这行文本中每个单词的长度.这 ...
- hdu 4548 第六周H题(美素数)
第六周H题 - 数论,晒素数 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u De ...
- CodeForces 478B 第六周比赛B题
B - B Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Descriptio ...
- CodeForces 569A 第六周比赛C踢
C - C Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- 第六周 E题 期望.....
Description Given a dice with n sides, you have to find the expected number of times you have to thr ...
- 第六周 N题
Description As Harry Potter series is over, Harry has no job. Since he wants to make quick money, (h ...
- HDU 1465 第六周L题
Description 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了! 做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的道理一样. ...
- HDU 1405 第六周 J题
Description Tomorrow is contest day, Are you all ready? We have been training for 45 days, and all ...
- HDU 2669 第六周 I题
Description The Sky is Sprite. The Birds is Fly in the Sky. The Wind is Wonderful. Blew Throw the ...
随机推荐
- iOS开发libWeChatSDK.a(WXApiObject.o)' does not contain bitcode.
在使用微信分享的时候可能会报错, 报错如下: ld: '/Users/gti/Documents/********/Lib/SDKExport/libWeChatSDK.a(WXApiObject.o ...
- java.util.concurrent.CountDownLatch
闭锁是一种同步工具类,可以延迟线程的进度直到闭锁到达终止状态. 闭锁的作用相当于一扇门,在闭锁到达结束状态之前,这扇门一直是关闭的,任何线程都不能通过这扇门,当闭锁到达结束状态时,这扇门会打开并允许所 ...
- jQuery formValidator表单验证插件
什么是jQuery formValidator? jQuery formValidator表单验证插件是客户端表单验证插件. 在做B/S开发的时候,我们经常涉及到很多表单验证,例如新用户注册,填写个人 ...
- hdu 1243 反恐训练营 最长公共字序列
此题的题意很明确,就是求最长公共子序列: #include<iostream> #include<algorithm> #include<cstdio> #incl ...
- Shanghai InfoSys .NET engineer telephone interview
Collect the answers,interested friends from research. 1,Interface and Abstract difference? 2,Generic ...
- 百度编辑器ueditor代码高亮效果前台不显示的解决方法
原因是你没有在你的内容页加载相应的css文件,这要如何解决呢? 经测试,只要插入以下两个文件即可解决问题: <link href="你的ueditor路径/ueditor/third- ...
- C# lock用法
当我们使用线程的时候,效率最高的方式当然是异步,即各个线程同时运行,其间不相互依赖和等待.但当不同的线程都需要访问某个资源的时候,就需要同步机制了,也就是说当对同一个资源进行读写的时候,我们要使该资源 ...
- 追访现代主流程序员的家庭事业观---禅宗派程序员KUROKY
Kuroky,一个被人遗忘的当代主流程序员. 在他的内心深处有着怎样的心路历程 他的快乐与悲伤,都是一个禅 独家专访kuroky: 记者:作为现代主流程序员,你内心的苦楚玉欢乐通过什么来发现? 大师: ...
- BeanDefinition的Resource定位——2
1.FileSystemXmlApplicationContext的实现 public class FileSystemXmlApplicationContext extends AbstractXm ...
- CSS Sprite 雪碧图制作
CSS Sprite 雪碧图,简单来说就是: 为了提高网页的性能,减少加载次数,将一些不会经常随网站内容变化的小图标,集中放在一张大图上,将该图应作为background-image 嵌入页面中,在需 ...